Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #76

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.1-alpha.82](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.81...v0.0.1-alpha.82) (2024-09-25)


### Bug Fixes

* download store ([5791d49](https://github.com/DIG-Network/dig-chia-sdk/commit/5791d499d589418600d5794b5fd6cf1028371420))

### [0.0.1-alpha.81](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.80...v0.0.1-alpha.81) (2024-09-25)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dignetwork/dig-sdk",
"version": "0.0.1-alpha.81",
"version": "0.0.1-alpha.82",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
17 changes: 12 additions & 5 deletions src/DigNetwork/PropagationServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,10 @@ export class PropagationServer {
const downloadTasks = [];

for (const [fileKey, fileData] of Object.entries(root.files)) {
const dataPath = getFilePathFromSha256((fileData as any).sha256, "data");
const dataPath = getFilePathFromSha256(
root.files[fileKey].sha256,
"data"
);
const label = Buffer.from(fileKey, "hex").toString("utf-8");
downloadTasks.push({ label, dataPath });
}
Expand Down Expand Up @@ -687,17 +690,19 @@ export class PropagationServer {

// Integrity check for the downloaded files was done during the download
// Here we want to make sure we got all the files or we reject the download session
/*for (const [fileKey, fileData] of Object.entries(root.files)) {
for (const [fileKey, fileData] of Object.entries(root.files)) {
const dataPath = getFilePathFromSha256(
(fileData as any).sha256,
root.files[fileKey].sha256,
"data"
);

const downloadPath = path.join(tempDir, storeId, dataPath);
if (!fs.existsSync(path.join(downloadPath, dataPath))) {
throw new Error(`Missing file!: ${Buffer.from(fileKey, "utf-8")}, aborting session.`);
throw new Error(
`Missing file: ${Buffer.from(fileKey, "utf-8")}, aborting session.`
);
}
}*/
}

// After all downloads are complete, copy from temp directory to the main directory
const destinationDir = path.join(STORE_PATH, storeId);
Expand All @@ -709,6 +714,8 @@ export class PropagationServer {
await dataStore.generateManifestFile();

console.log(green(`✔ All files have been downloaded to ${storeId}.`));
} catch (error) {
console.log(red("✖ Error downloading files:"), error);
} finally {
// Clean up the temporary directory
fsExtra.removeSync(tempDir);
Expand Down
Loading