|
|
@ -151,20 +151,21 @@ class model(dict):
|
|
|
|
import uuid
|
|
|
|
import uuid
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
output_path = "{}/{}".format(self.__datastore_path, self['uuid'])
|
|
|
|
output_path = os.path.join(self.__datastore_path, self['uuid'])
|
|
|
|
|
|
|
|
|
|
|
|
self.ensure_data_dir_exists()
|
|
|
|
self.ensure_data_dir_exists()
|
|
|
|
|
|
|
|
snapshot_fname = os.path.join(output_path, str(uuid.uuid4()))
|
|
|
|
|
|
|
|
|
|
|
|
snapshot_fname = "{}/{}.stripped.txt".format(output_path, uuid.uuid4())
|
|
|
|
|
|
|
|
logging.debug("Saving history text {}".format(snapshot_fname))
|
|
|
|
logging.debug("Saving history text {}".format(snapshot_fname))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# in /diff/ we are going to assume for now that it's UTF-8 when reading
|
|
|
|
with open(snapshot_fname, 'wb') as f:
|
|
|
|
with open(snapshot_fname, 'wb') as f:
|
|
|
|
f.write(contents)
|
|
|
|
f.write(contents)
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
|
|
# Append to index
|
|
|
|
# Append to index
|
|
|
|
# @todo check last char was \n
|
|
|
|
# @todo check last char was \n
|
|
|
|
index_fname = "{}/history.txt".format(output_path)
|
|
|
|
index_fname = os.path.join(output_path, "history.txt")
|
|
|
|
with open(index_fname, 'a') as f:
|
|
|
|
with open(index_fname, 'a') as f:
|
|
|
|
f.write("{},{}\n".format(timestamp, snapshot_fname))
|
|
|
|
f.write("{},{}\n".format(timestamp, snapshot_fname))
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|