Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
add logs for restore api
Browse files Browse the repository at this point in the history
  • Loading branch information
burnerlee committed Mar 5, 2024
1 parent 785c2b6 commit 7a267b0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
9 changes: 4 additions & 5 deletions dist/setup-gradle/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70277,7 +70277,6 @@ const logger_1 = __importDefault(__nccwpck_require__(4636));
const state_1 = __importDefault(__nccwpck_require__(9738));
const path_1 = __importDefault(__nccwpck_require__(1017));
const node_fetch_1 = __importDefault(__nccwpck_require__(467));
const cache_utils_1 = __nccwpck_require__(1678);
class ValidationError extends Error {
}
exports.ValidationError = ValidationError;
Expand All @@ -70301,8 +70300,9 @@ function restoreCache(paths, primaryKey, restoreKeys = []) {
const data = yield response.json();
switch (statusCode) {
case 200:
const cachePath = data.path;
const cachePath = String(data.path);
if (fs_1.default.existsSync(cachePath)) {
logger_1.default.info("restoring cache from " + cachePath);
const metadataPath = data.metadata_file_path;
const metadata = JSON.parse(fs_1.default.readFileSync(metadataPath, 'utf8'));
const srcFiles = metadata.files.map((file) => path_1.default.resolve(cachePath, file));
Expand All @@ -70315,9 +70315,8 @@ function restoreCache(paths, primaryKey, restoreKeys = []) {
});
}
});
for (const file of srcFiles) {
yield (0, cache_utils_1.tryDelete)(file);
}
fs_1.default.rmSync(cachePath, { recursive: true });
logger_1.default.info("removing temp cache path", cachePath);
logger_1.default.info("restored cache to " + gradleUserHome);
logger_1.default.info("time taken to restore cache: " + (Date.now() - timeCpStarted) + "ms");
return new CacheEntry(key, 0);
Expand Down
2 changes: 1 addition & 1 deletion dist/setup-gradle/main/index.js.map

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/setup-gradle/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70301,7 +70301,6 @@ const logger_1 = __importDefault(__nccwpck_require__(4636));
const state_1 = __importDefault(__nccwpck_require__(9738));
const path_1 = __importDefault(__nccwpck_require__(1017));
const node_fetch_1 = __importDefault(__nccwpck_require__(467));
const cache_utils_1 = __nccwpck_require__(1678);
class ValidationError extends Error {
}
exports.ValidationError = ValidationError;
Expand All @@ -70325,8 +70324,9 @@ function restoreCache(paths, primaryKey, restoreKeys = []) {
const data = yield response.json();
switch (statusCode) {
case 200:
const cachePath = data.path;
const cachePath = String(data.path);
if (fs_1.default.existsSync(cachePath)) {
logger_1.default.info("restoring cache from " + cachePath);
const metadataPath = data.metadata_file_path;
const metadata = JSON.parse(fs_1.default.readFileSync(metadataPath, 'utf8'));
const srcFiles = metadata.files.map((file) => path_1.default.resolve(cachePath, file));
Expand All @@ -70339,9 +70339,8 @@ function restoreCache(paths, primaryKey, restoreKeys = []) {
});
}
});
for (const file of srcFiles) {
yield (0, cache_utils_1.tryDelete)(file);
}
fs_1.default.rmSync(cachePath, { recursive: true });
logger_1.default.info("removing temp cache path", cachePath);
logger_1.default.info("restored cache to " + gradleUserHome);
logger_1.default.info("time taken to restore cache: " + (Date.now() - timeCpStarted) + "ms");
return new CacheEntry(key, 0);
Expand Down
2 changes: 1 addition & 1 deletion dist/setup-gradle/post/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions sources/src/config/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ inputs:
dependency-graph: disabled
dependency-graph-continue-on-failure: "false"
gradle-user-home: "build-cache"
cache-shared-directory: /data/cache
project-directory: /workspace/code
cache-shared-directory: /Users/burnerlee/test-shared-cache
project-directory: /Users/burnerlee/Projects/random/yetCalc

project-name: topcorn
cache-manager-endpoint: https://cache-server.ea37c239a8.dashwave.live
cache-manager-endpoint: http://localhost:5678
project-branch: master
4 changes: 3 additions & 1 deletion sources/src/s3-cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export async function restoreCache(paths: string[], primaryKey: string, restoreK
const data = await response.json();
switch (statusCode) {
case 200:
const cachePath = data.path;
const cachePath = String(data.path);
if (fs.existsSync(cachePath)) {
logger.info("restoring cache from " + cachePath)
const metadataPath = data.metadata_file_path;
const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf8'));
const srcFiles = metadata.files.map((file: string) => path.resolve(cachePath, file));
Expand All @@ -51,6 +52,7 @@ export async function restoreCache(paths: string[], primaryKey: string, restoreK
}
})
fs.rmSync(cachePath, { recursive: true })
logger.info("removing temp cache path", cachePath)
logger.info("restored cache to " + gradleUserHome)
logger.info("time taken to restore cache: " + (Date.now() - timeCpStarted) + "ms")

Expand Down

0 comments on commit 7a267b0

Please sign in to comment.