diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-03-13 10:52:57 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-15 09:47:41 +0000 |
commit | 1622a43da4d2de3483013abdae1b7a7b8d478a0c (patch) | |
tree | 3036a4fc86b956059f8193c259600599af55e084 /buildstream/_cas | |
parent | 594eda8aa3e387841085c6a59d0f7627142a8514 (diff) | |
download | buildstream-1622a43da4d2de3483013abdae1b7a7b8d478a0c.tar.gz |
cascache: atomically save size via tmpdir instead
Instead of doing the atomic 'mv into place' using a temporary file in
the 'cas' directory, use the sibling 'tmp' directory instead.
This will avoid the situation where CacheSizeJob encounters a temporary
file in the cas directory. This can happen because CacheSizeJob does not
always run with an exclusive lock on the cas directory, and BuildQueue
updates the cache size whenever a BuildJob completes.
Diffstat (limited to 'buildstream/_cas')
-rw-r--r-- | buildstream/_cas/cascache.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py index 04a09299a..2be16067b 100644 --- a/buildstream/_cas/cascache.py +++ b/buildstream/_cas/cascache.py @@ -1187,7 +1187,7 @@ class CASQuota: def _write_cache_size(self, size): assert isinstance(size, int) size_file_path = os.path.join(self.casdir, CACHE_SIZE_FILE) - with utils.save_file_atomic(size_file_path, "w") as f: + with utils.save_file_atomic(size_file_path, "w", tempdir=self.cas.tmpdir) as f: f.write(str(size)) # _get_cache_volume_size() |