1
0
mirror of https://github.com/mon/ifstools.git synced 2024-11-30 19:54:27 +01:00

Fix files with no timestamp

This commit is contained in:
Will Toohey 2019-01-23 10:26:17 +10:00
parent 042f3697db
commit 16b0f761a0
2 changed files with 10 additions and 2 deletions

View File

@ -8,7 +8,13 @@ from .. import utils
class GenericFile(Node):
def from_xml(self, element):
self.start, self.size, self.time = self._split_ints(element.text)
info = self._split_ints(element.text)
# sometimes we don't get a timestamp
if len(info) == 2:
self.start, self.size = info
self.time = -1
else:
self.start, self.size, self.time = info
def from_filesystem(self, folder):
self.base_path = self.parent.base_path

View File

@ -21,4 +21,6 @@ def save_with_timestamp(filename, data, timestamp):
mkdir_silent(os.path.dirname(filename))
with open(filename, 'wb') as f:
f.write(data)
# we store invalid timestamps as -1
if timestamp >= 0:
os.utime(filename, (timestamp,timestamp))