Skip to content

Commit

Permalink
serialization bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jkelleyrtp committed Jan 29, 2025
1 parent 5bbbdb9 commit 829dfd6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87392,6 +87392,7 @@ async function run() {
const restoreJson = external_path_default().join(config_CARGO_HOME, "incremental-restore.json");
const restoreString = await external_fs_default().promises.readFile(restoreJson, "utf8");
const restoreData = JSON.parse(restoreString);
lib_core.debug(`restoreData: ${JSON.stringify(restoreData)}`);
if (restoreData.roots.length == 0) {
throw new Error("No incremental roots found");
}
Expand Down
13 changes: 8 additions & 5 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87340,8 +87340,11 @@ async function rmRF(dirName) {


async function saveMtimes(targetDirs) {
let times = new Map();
let stack = new Array();
let data = {
roots: [],
times: {},
};
let stack = [];
// Collect all the incremental files
for (const dir of targetDirs) {
for (const maybeProfile of await external_fs_default().promises.readdir(dir)) {
Expand All @@ -87353,7 +87356,7 @@ async function saveMtimes(targetDirs) {
}
}
// Save the stack as the roots - we cache these directly
let roots = stack.slice();
data.roots = stack.slice();
while (stack.length > 0) {
const dirName = stack.pop();
const dir = await external_fs_default().promises.opendir(dirName);
Expand All @@ -87364,11 +87367,11 @@ async function saveMtimes(targetDirs) {
else {
const fileName = external_path_default().join(dirName, dirent.name);
const { mtime } = await external_fs_default().promises.stat(fileName);
times.set(fileName, mtime.getTime());
data.times[fileName] = mtime.getTime();
}
}
}
return { roots, times: times };
return data;
}

;// CONCATENATED MODULE: ./src/save.ts
Expand Down
19 changes: 12 additions & 7 deletions src/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ import fs from "fs";
import path from "path";

export type MtimeData = {
roots: Array<string>,
times: Map<string, number>
roots: string[],
times: {
[key: string]: number
}
};

export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
let times = new Map<string, number>();
let stack = new Array<string>();
let data: MtimeData = {
roots: [],
times: {},
};
let stack: string[] = [];

// Collect all the incremental files
for (const dir of targetDirs) {
Expand All @@ -28,7 +33,7 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
}

// Save the stack as the roots - we cache these directly
let roots = stack.slice();
data.roots = stack.slice();

while (stack.length > 0) {
const dirName = stack.pop()!;
Expand All @@ -40,10 +45,10 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
} else {
const fileName = path.join(dirName, dirent.name);
const { mtime } = await fs.promises.stat(fileName);
times.set(fileName, mtime.getTime());
data.times[fileName] = mtime.getTime();
}
}
}

return { roots, times: times };
return data;
}
2 changes: 2 additions & 0 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ async function run() {
const restoreString = await fs.promises.readFile(restoreJson, "utf8");
const restoreData: MtimeData = JSON.parse(restoreString);

core.debug(`restoreData: ${JSON.stringify(restoreData)}`);

if (restoreData.roots.length == 0) {
throw new Error("No incremental roots found");
}
Expand Down

0 comments on commit 829dfd6

Please sign in to comment.