mirror of
https://github.com/Swatinem/rust-cache
synced 2025-06-08 17:43:25 +00:00
serialization bugs
This commit is contained in:
parent
5bbbdb9115
commit
829dfd6b08
4 changed files with 23 additions and 12 deletions
1
dist/restore/index.js
vendored
1
dist/restore/index.js
vendored
|
@ -87392,6 +87392,7 @@ async function run() {
|
||||||
const restoreJson = external_path_default().join(config_CARGO_HOME, "incremental-restore.json");
|
const restoreJson = external_path_default().join(config_CARGO_HOME, "incremental-restore.json");
|
||||||
const restoreString = await external_fs_default().promises.readFile(restoreJson, "utf8");
|
const restoreString = await external_fs_default().promises.readFile(restoreJson, "utf8");
|
||||||
const restoreData = JSON.parse(restoreString);
|
const restoreData = JSON.parse(restoreString);
|
||||||
|
lib_core.debug(`restoreData: ${JSON.stringify(restoreData)}`);
|
||||||
if (restoreData.roots.length == 0) {
|
if (restoreData.roots.length == 0) {
|
||||||
throw new Error("No incremental roots found");
|
throw new Error("No incremental roots found");
|
||||||
}
|
}
|
||||||
|
|
13
dist/save/index.js
vendored
13
dist/save/index.js
vendored
|
@ -87340,8 +87340,11 @@ async function rmRF(dirName) {
|
||||||
|
|
||||||
|
|
||||||
async function saveMtimes(targetDirs) {
|
async function saveMtimes(targetDirs) {
|
||||||
let times = new Map();
|
let data = {
|
||||||
let stack = new Array();
|
roots: [],
|
||||||
|
times: {},
|
||||||
|
};
|
||||||
|
let stack = [];
|
||||||
// Collect all the incremental files
|
// Collect all the incremental files
|
||||||
for (const dir of targetDirs) {
|
for (const dir of targetDirs) {
|
||||||
for (const maybeProfile of await external_fs_default().promises.readdir(dir)) {
|
for (const maybeProfile of await external_fs_default().promises.readdir(dir)) {
|
||||||
|
@ -87353,7 +87356,7 @@ async function saveMtimes(targetDirs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Save the stack as the roots - we cache these directly
|
// Save the stack as the roots - we cache these directly
|
||||||
let roots = stack.slice();
|
data.roots = stack.slice();
|
||||||
while (stack.length > 0) {
|
while (stack.length > 0) {
|
||||||
const dirName = stack.pop();
|
const dirName = stack.pop();
|
||||||
const dir = await external_fs_default().promises.opendir(dirName);
|
const dir = await external_fs_default().promises.opendir(dirName);
|
||||||
|
@ -87364,11 +87367,11 @@ async function saveMtimes(targetDirs) {
|
||||||
else {
|
else {
|
||||||
const fileName = external_path_default().join(dirName, dirent.name);
|
const fileName = external_path_default().join(dirName, dirent.name);
|
||||||
const { mtime } = await external_fs_default().promises.stat(fileName);
|
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
|
;// CONCATENATED MODULE: ./src/save.ts
|
||||||
|
|
|
@ -8,13 +8,18 @@ import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export type MtimeData = {
|
export type MtimeData = {
|
||||||
roots: Array<string>,
|
roots: string[],
|
||||||
times: Map<string, number>
|
times: {
|
||||||
|
[key: string]: number
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
|
export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
|
||||||
let times = new Map<string, number>();
|
let data: MtimeData = {
|
||||||
let stack = new Array<string>();
|
roots: [],
|
||||||
|
times: {},
|
||||||
|
};
|
||||||
|
let stack: string[] = [];
|
||||||
|
|
||||||
// Collect all the incremental files
|
// Collect all the incremental files
|
||||||
for (const dir of targetDirs) {
|
for (const dir of targetDirs) {
|
||||||
|
@ -28,7 +33,7 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the stack as the roots - we cache these directly
|
// Save the stack as the roots - we cache these directly
|
||||||
let roots = stack.slice();
|
data.roots = stack.slice();
|
||||||
|
|
||||||
while (stack.length > 0) {
|
while (stack.length > 0) {
|
||||||
const dirName = stack.pop()!;
|
const dirName = stack.pop()!;
|
||||||
|
@ -40,10 +45,10 @@ export async function saveMtimes(targetDirs: string[]): Promise<MtimeData> {
|
||||||
} else {
|
} else {
|
||||||
const fileName = path.join(dirName, dirent.name);
|
const fileName = path.join(dirName, dirent.name);
|
||||||
const { mtime } = await fs.promises.stat(fileName);
|
const { mtime } = await fs.promises.stat(fileName);
|
||||||
times.set(fileName, mtime.getTime());
|
data.times[fileName] = mtime.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { roots, times: times };
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ async function run() {
|
||||||
const restoreString = await fs.promises.readFile(restoreJson, "utf8");
|
const restoreString = await fs.promises.readFile(restoreJson, "utf8");
|
||||||
const restoreData: MtimeData = JSON.parse(restoreString);
|
const restoreData: MtimeData = JSON.parse(restoreString);
|
||||||
|
|
||||||
|
core.debug(`restoreData: ${JSON.stringify(restoreData)}`);
|
||||||
|
|
||||||
if (restoreData.roots.length == 0) {
|
if (restoreData.roots.length == 0) {
|
||||||
throw new Error("No incremental roots found");
|
throw new Error("No incremental roots found");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue