Skip to content

Commit 181e6a0

Browse files
committed
networkDesign: create cache symlink when resuming task
The main cache directory may have been reset when the task is resumed, so we need to create the symlink in that case also.
1 parent c8f84b8 commit 181e6a0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/transition-backend/src/services/networkDesign/transitNetworkDesign/TransitNetworkDesignJobWrapper.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ export class TransitNetworkDesignJobWrapper<
207207
`${absoluteCacheDirectory}/services.capnpbin`,
208208
true
209209
);
210+
211+
this.addCacheSymlink();
212+
213+
console.log(`Prepared cache directory files to ${absoluteCacheDirectory} from ${mainCacheDirectory}`);
214+
};
215+
216+
addCacheSymlink = () => {
217+
const absoluteCacheDirectory = this.getCacheDirectory();
218+
const mainCacheDirectory = `${fileManager.directoryManager.cacheDirectory}/${config.projectShortname}`;
219+
210220
// FIXME HACK Add a symlink from mainCacheDirectory to the job cache
211221
// directory because the path in the json to capnp server is relative to
212222
// main cache path Create symbolic link pointing to the job cache
@@ -234,8 +244,6 @@ export class TransitNetworkDesignJobWrapper<
234244
} catch (error) {
235245
console.warn(`Failed to create symbolic link: ${error}`);
236246
}
237-
238-
console.log(`Prepared cache directory files to ${absoluteCacheDirectory} from ${mainCacheDirectory}`);
239247
};
240248

241249
async addMessages(messages: {

packages/transition-backend/src/services/networkDesign/transitNetworkDesign/evolutionary/EvolutionaryTransitNetworkDesignJob.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ class EvolutionaryTransitNetworkDesignJobExecutor extends TransitNetworkDesignJo
259259
// FIXME We need to have the paths and lines loaded in a CollectionManager to save the scenarios and re-generate schedules at the end. But not the whole data
260260
await this.loadServerData(serviceLocator.socketEventManager);
261261

262+
// Add the symlink to the cache data, the main cache may have been reinitialized since the last execution.
263+
this.addCacheSymlink();
264+
262265
// Get the simulated lines from cache, to make sure the order is the same as before
263266
const simulatedLineCollection = await lineCollectionFromCache(this.getCacheDirectory() + '/simulatedLines');
264267
this.simulatedLineCollection = simulatedLineCollection;

0 commit comments

Comments
 (0)