Skip to content

Commit

Permalink
fix integrity check
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenVoich committed Oct 31, 2023
1 parent 562a8fc commit 3c03931
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/main/main-canister.mo
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ actor {
for (fileId in publicFileIds.vals()) {
let ?hasher = publishingFileHashers.get(fileId) else return #err("Hasher not found");
hashByFileId.put(fileId, hasher.sum());
publishingFileHashers.delete(fileId);
};

// finish uploads
Expand Down Expand Up @@ -757,7 +758,7 @@ actor {
let #ok(fileMeta) = await storage.getFileMeta(fileId) else Debug.trap("File meta '" # fileId # "' not found");

let hasher = Sha256.Digest(#sha256);
for (i in Iter.range(1, fileMeta.chunkCount)) {
for (i in Iter.range(0, fileMeta.chunkCount - 1)) {
let #ok(chunk) = await storage.downloadChunk(fileId, i) else Debug.trap("File chunk '" # fileId # "' not found");
hasher.writeBlob(chunk);
};
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ program
.option('--dev', 'Remove from dev-dependencies instead of dependencies')
.option('--verbose', 'Show more information')
.option('--dry-run', 'Do not actually remove anything')
.addOption(new Option('--lockfile <lockfile>', 'Lockfile action').choices(['save', 'check', 'ignore']))
.addOption(new Option('--lockfile <lockfile>', 'Lockfile action').choices(['save', 'ignore']))
.action(async (pkg, options) => {
if (!checkConfigFile()) {
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {checkIntegrity} from '../integrity.js';
type UpdateOptions = {
verbose?: boolean;
dev?: boolean;
lockfile?: 'save' | 'check' | 'ignore';
lockfile?: 'save' | 'ignore';
};

export async function update(pkg?: string, {lockfile}: UpdateOptions = {}) {
Expand Down
1 change: 1 addition & 0 deletions cli/integrity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function checkIntegrity(lock?: 'save' | 'check' | 'ignore') {

if (lock === 'save') {
await saveLockFile();
await checkLockFile(force);
}
else if (lock === 'check') {
await checkLockFile(force);
Expand Down

0 comments on commit 3c03931

Please sign in to comment.