Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Apr 10, 2024
1 parent 569f284 commit d1ce8f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion examples/stable_memory/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function getTests(
name: 'stable size',
test: async () => {
const result = await stableMemoryCanister.stableSize();
console.log(result);

return {
Ok: result === 513
Expand Down
13 changes: 6 additions & 7 deletions src/compiler/file_uploader/upload_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ export async function uploadFile(
chunkSize: number,
actor: UploaderActor
) {
const uploadStartTime = process.hrtime.bigint();
const fileSize = (await stat(srcPath)).size;
const file = await open(srcPath, 'r');
if (!(await shouldBeUploaded(srcPath, destPath, actor))) {
file.close();
return;
}
const uploadStartTime = process.hrtime.bigint();
const fileSize = (await stat(srcPath)).size;
const file = await open(srcPath, 'r');
for (let startIndex = 0; startIndex <= fileSize; startIndex += chunkSize) {
let buffer = Buffer.alloc(chunkSize);
const { buffer: bytesToUpload, bytesRead } = await file.read(
Expand Down Expand Up @@ -81,9 +80,9 @@ async function shouldBeUploaded(
actor: UploaderActor
): Promise<boolean> {
const localHash = (await hashFile(srcPath)).toString('hex');
const canisterHash = await actor.get_file_hash(destPath);
if (canisterHash.length === 0) {
const canisterHashOption = await actor.get_file_hash(destPath);
if (canisterHashOption.length === 0) {
return true;
}
return localHash !== canisterHash[0];
return localHash !== canisterHashOption[0];
}

0 comments on commit d1ce8f8

Please sign in to comment.