@qvac/sdk 0.2.7-dev.1761295911.0436ccb → 0.2.7-dev.1761566029.f834aa3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,14 +34,13 @@ async function setupHyperdrive(hyperdriveKey, corestoreDir) {
|
|
|
34
34
|
const drive = new Hyperdrive(corestore, Buffer.from(hyperdriveKey, "hex"));
|
|
35
35
|
await drive.ready();
|
|
36
36
|
const swarm = new Hyperswarm();
|
|
37
|
-
|
|
37
|
+
const doneFindingPeers = drive.findingPeers();
|
|
38
38
|
swarm.on("connection", (connection) => {
|
|
39
39
|
console.log(`🤝 Connected to peer for hyperdrive download`);
|
|
40
40
|
drive.replicate(connection);
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
doneFindingPeers();
|
|
42
|
+
swarm.join(drive.discoveryKey, { server: false, client: true });
|
|
43
|
+
swarm.flush().then(doneFindingPeers, doneFindingPeers);
|
|
45
44
|
return { corestore, drive, swarm, corestoreDir };
|
|
46
45
|
}
|
|
47
46
|
async function cleanupHyperdrive(setup) {
|
|
@@ -68,10 +67,15 @@ export async function deleteCorestoreDirectory(corestoreDir) {
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
async function findFileInHyperdrive(drive, modelFileName) {
|
|
70
|
+
if (drive.core.length === 0) {
|
|
71
|
+
// this method will update the length of the core using the first peer it finds
|
|
72
|
+
// this will ensure that the hyperdrive is usable
|
|
73
|
+
await drive.core.update();
|
|
74
|
+
}
|
|
71
75
|
const paths = [modelFileName, `/${modelFileName}`, `./${modelFileName}`];
|
|
72
76
|
for (const pathVariation of paths) {
|
|
73
77
|
try {
|
|
74
|
-
const entry = await drive.entry(pathVariation);
|
|
78
|
+
const entry = await drive.entry(pathVariation, { wait: true });
|
|
75
79
|
if (entry) {
|
|
76
80
|
return { entry, targetPath: pathVariation };
|
|
77
81
|
}
|
|
@@ -85,7 +89,7 @@ async function findFileInHyperdrive(drive, modelFileName) {
|
|
|
85
89
|
try {
|
|
86
90
|
// Try both with and without leading slash
|
|
87
91
|
for (const prefix of ["/", ""]) {
|
|
88
|
-
const files = drive.list(prefix,
|
|
92
|
+
const files = drive.list(prefix, { recursive: true, wait: true });
|
|
89
93
|
for await (const file of files) {
|
|
90
94
|
availableFiles.push(file.key);
|
|
91
95
|
}
|