Fix lib caching

pull/310/head
Frostebite 2021-12-27 02:15:59 +00:00
parent f2ef9335c1
commit 63088a2621
3 changed files with 22 additions and 11 deletions

15
dist/index.js vendored
View File

@ -655,14 +655,14 @@ class SetupRemoteRepository {
static libraryCaching(libraryCacheFolder) { static libraryCaching(libraryCacheFolder) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.logCli(`Starting checks of cache for the Unity project Library and git LFS files`); cloud_runner_logger_1.default.logCli(`Starting checks of cache for the Unity project Library and git LFS files`);
if (!fs_1.default.existsSync(libraryCacheFolder)) {
fs_1.default.mkdirSync(libraryCacheFolder);
}
cloud_runner_logger_1.default.logCli(`Library Caching`); cloud_runner_logger_1.default.logCli(`Library Caching`);
//if the unity git project has included the library delete it and echo a warning //if the unity git project has included the library delete it and echo a warning
if (fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) { if (fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull, { recursive: true }); fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull, { recursive: true });
cloud_runner_logger_1.default.logCli(`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`); cloud_runner_logger_1.default.logCli(`!Warning!: The Unity library was included in the git repository`);
}
if (!fs_1.default.existsSync(libraryCacheFolder)) {
fs_1.default.mkdirSync(libraryCacheFolder);
} }
//Restore library cache //Restore library cache
const latestLibraryCacheFile = yield remote_client_system_1.RemoteClientSystem.Run(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`); const latestLibraryCacheFile = yield remote_client_system_1.RemoteClientSystem.Run(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
@ -673,6 +673,13 @@ class SetupRemoteRepository {
cloud_runner_logger_1.default.logCli(`Library cache exists`); cloud_runner_logger_1.default.logCli(`Library cache exists`);
yield remote_client_system_1.RemoteClientSystem.Run(`unzip -q "${latestCacheFilePath}" -d "$projectPathFull"`); yield remote_client_system_1.RemoteClientSystem.Run(`unzip -q "${latestCacheFilePath}" -d "$projectPathFull"`);
} }
else {
cloud_runner_logger_1.default.logCli(`Library cache doesn't exist`);
if (latestLibraryCacheFile !== ``) {
yield remote_client_system_1.RemoteClientSystem.Run(`tree`);
throw new Error(`Failed to get library cache, but cache hit was found (${latestLibraryCacheFile})`);
}
}
}); });
} }
static createLFSHashFiles() { static createLFSHashFiles() {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -118,16 +118,14 @@ export class SetupRemoteRepository {
private static async libraryCaching(libraryCacheFolder: string) { private static async libraryCaching(libraryCacheFolder: string) {
CloudRunnerLogger.logCli(`Starting checks of cache for the Unity project Library and git LFS files`); CloudRunnerLogger.logCli(`Starting checks of cache for the Unity project Library and git LFS files`);
if (!fs.existsSync(libraryCacheFolder)) {
fs.mkdirSync(libraryCacheFolder);
}
CloudRunnerLogger.logCli(`Library Caching`); CloudRunnerLogger.logCli(`Library Caching`);
//if the unity git project has included the library delete it and echo a warning //if the unity git project has included the library delete it and echo a warning
if (fs.existsSync(CloudRunnerState.libraryFolderFull)) { if (fs.existsSync(CloudRunnerState.libraryFolderFull)) {
fs.rmdirSync(CloudRunnerState.libraryFolderFull, { recursive: true }); fs.rmdirSync(CloudRunnerState.libraryFolderFull, { recursive: true });
CloudRunnerLogger.logCli( CloudRunnerLogger.logCli(`!Warning!: The Unity library was included in the git repository`);
`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`, }
); if (!fs.existsSync(libraryCacheFolder)) {
fs.mkdirSync(libraryCacheFolder);
} }
//Restore library cache //Restore library cache
const latestLibraryCacheFile = await RemoteClientSystem.Run(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`); const latestLibraryCacheFile = await RemoteClientSystem.Run(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
@ -137,6 +135,12 @@ export class SetupRemoteRepository {
if (fs.existsSync(latestCacheFilePath)) { if (fs.existsSync(latestCacheFilePath)) {
CloudRunnerLogger.logCli(`Library cache exists`); CloudRunnerLogger.logCli(`Library cache exists`);
await RemoteClientSystem.Run(`unzip -q "${latestCacheFilePath}" -d "$projectPathFull"`); await RemoteClientSystem.Run(`unzip -q "${latestCacheFilePath}" -d "$projectPathFull"`);
} else {
CloudRunnerLogger.logCli(`Library cache doesn't exist`);
if (latestLibraryCacheFile !== ``) {
await RemoteClientSystem.Run(`tree`);
throw new Error(`Failed to get library cache, but cache hit was found (${latestLibraryCacheFile})`);
}
} }
} }