writeDownloadMetadata function

Future<void> writeDownloadMetadata({
  1. required String localDir,
  2. required String filename,
  3. required String commitHash,
  4. required String etag,
})

Write metadata about a file in the local directory related to a download process.

Args: local_dir (Path): Path to the local directory in which files are downloaded.

Implementation

Future<void> writeDownloadMetadata({
  required String localDir,
  required String filename,
  required String commitHash,
  required String etag,
}) async {
  final paths = await getLocalDownloadPaths(localDir: localDir, filename: filename);
  await WeakFileLock(paths.lockPath, () async {
    await File(paths.metadataPath).writeAsString('$commitHash\n$etag\n${unixTimestamp()}\n');
  });
}