file: use _get_tempfile() in metric storage

This changes the temporary file used to be stored in the specific
temporary directory we now use.

Change-Id: I3899c1cbe168241d2b394033e470cb9428ba33fb
This commit is contained in:
Julien Danjou
2015-08-18 12:26:36 +02:00
parent c1a7e473e7
commit 57412c411b

View File

@@ -158,11 +158,10 @@ class FileStorage(_carbonara.CarbonaraBasedStorage):
self._delete_measures_files_for_metric_id(metric.id, files)
def _store_metric_measures(self, metric, aggregation, data):
atomic_path = self._build_metric_path(metric, aggregation)
path = '%s.tmp' % atomic_path
with open(path, 'wb') as aggregation_file:
aggregation_file.write(data)
os.rename(path, atomic_path)
tmpfile = self._get_tempfile()
tmpfile.write(data)
tmpfile.close()
os.rename(tmpfile.name, self._build_metric_path(metric, aggregation))
def delete_metric(self, metric):
path = self._build_metric_path(metric)