Skip to content

Commit

Permalink
Merge pull request #1966 from demergent-labs/stable_files
Browse files Browse the repository at this point in the history
Stable files
  • Loading branch information
lastmjs authored Aug 6, 2024
2 parents ebc6e70 + 9d60261 commit 64119c5
Show file tree
Hide file tree
Showing 37 changed files with 830 additions and 653 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/simple_erc20",
"tests/end_to_end/candid_rpc/class_syntax/simple_user_accounts",
"tests/end_to_end/candid_rpc/class_syntax/stable_b_tree_map_instruction_threshold",
"tests/end_to_end/candid_rpc/class_syntax/stable_memory",
"tests/end_to_end/candid_rpc/class_syntax/stable_structures",
"tests/end_to_end/candid_rpc/class_syntax/timers",
"tests/end_to_end/candid_rpc/class_syntax/tuple_types",
Expand Down Expand Up @@ -232,7 +231,6 @@ jobs:
"tests/end_to_end/candid_rpc/functional_syntax/simple_erc20",
"tests/end_to_end/candid_rpc/functional_syntax/simple_user_accounts",
"tests/end_to_end/candid_rpc/functional_syntax/stable_b_tree_map_instruction_threshold",
"tests/end_to_end/candid_rpc/functional_syntax/stable_memory",
"tests/end_to_end/candid_rpc/functional_syntax/stable_structures",
"tests/end_to_end/candid_rpc/functional_syntax/timers",
"tests/end_to_end/candid_rpc/functional_syntax/tuple_types",
Expand Down
56 changes: 42 additions & 14 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions global_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wasi2ic version: wasi2ic v0.2.0 (https://github.com/wasm-forge/wasi2ic?rev=806c3558aad24224852a9582f018178402cb3679#806c3558):
wasi2ic

node version: v20.11.0

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)
2 changes: 1 addition & 1 deletion scripts/file_generator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function fillFileWithRandomBytes(
for (let i = 0; i < totalChunks; i++) {
const remainingBytes = sizeInBytes - i * defaultChunkSize;
const chunkSize = Math.min(remainingBytes, defaultChunkSize);
const randomBytes = await createRandomBytes(chunkSize);
const randomBytes = createRandomBytes(chunkSize);
await appendFile(path, randomBytes);
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest_isolate_modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ fs.writeFile(jestConfigPath, newJestConfigContent, 'utf8', (err) => {
return;
}

console.log('jest.config.js successfully overwritten.');
console.info('jest.config.js successfully overwritten.');
});
2 changes: 1 addition & 1 deletion src/compiler/file_uploader/incomplete_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function hasValidHash(
actor: UploaderActor
): Promise<boolean> {
try {
const hashOption = await actor.get_file_hash(path);
const hashOption = await actor._azle_get_file_hash(path);
return hashOption.length === 1;
} catch {
return false;
Expand Down
7 changes: 5 additions & 2 deletions src/compiler/file_uploader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export async function uploadFiles(
canisterName: string,
paths: [Src, Dest][]
): Promise<void> {
if (paths.length === 0) {
if (
paths.length === 0 ||
process.env.AZLE_DISABLE_AUTO_FILE_UPLOAD === 'true'
) {
return;
}

Expand All @@ -30,7 +33,7 @@ export async function uploadFiles(
}

console.info(
'Finished uploading files. Waiting for file hashing to finish...'
'Finished uploading files. Waiting for all chunks to finish uploading...' // TODO remove after https://github.com/demergent-labs/azle/issues/1996 is complete
);

onBeforeExit(expandedPaths, actor);
Expand Down
29 changes: 5 additions & 24 deletions src/compiler/file_uploader/on_before_exit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Dest, Src } from '.';
import { getListOfIncompleteFiles } from './incomplete_files';
import { getOngoingHashingJobs, OngoingHashingJob } from './ongoing_hashes';
import { UploaderActor } from './uploader_actor';

export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
let hashingComplete = false;
let cleanUpComplete = false;
let ongoingHashingJobs: OngoingHashingJob[] = [];

process.on('beforeExit', async () => {
if (cleanUpComplete) {
Expand All @@ -17,26 +14,10 @@ export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
return;
}

if (hashingComplete) {
await cleanup(paths, actor);
cleanUpComplete = true;
return;
}

ongoingHashingJobs = await getOngoingHashingJobs(
paths,
ongoingHashingJobs,
actor
);

hashingComplete = ongoingHashingJobs.length === 0;

if (!hashingComplete) {
console.info(
`Waiting 5 seconds before checking hashing status again...`
);
await new Promise((resolve) => setTimeout(resolve, 5000));
}
console.info('Cleaning up incomplete files');
await cleanup(paths, actor);
cleanUpComplete = true;
return;
});
}

Expand All @@ -46,6 +27,6 @@ async function cleanup(
): Promise<void> {
const incompleteFiles = await getListOfIncompleteFiles(paths, actor);
for (const [_, path] of incompleteFiles) {
await actor.clear_file_and_info(path);
await actor._azle_clear_file_and_info(path);
}
}
Loading

0 comments on commit 64119c5

Please sign in to comment.