From 955357739798398f88b74212771a3c8f1d1de1ca Mon Sep 17 00:00:00 2001 From: Stuart Buchanan <stuart_d_buchanan@yahoo.co.uk> Date: Sun, 16 Feb 2020 20:27:44 +0000 Subject: [PATCH] Add support for tarballs in terrasync --- scripts/python/TerraSync/terrasync/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/python/TerraSync/terrasync/main.py b/scripts/python/TerraSync/terrasync/main.py index 8e4bcc5fb..82ffb7635 100755 --- a/scripts/python/TerraSync/terrasync/main.py +++ b/scripts/python/TerraSync/terrasync/main.py @@ -184,6 +184,7 @@ class DirIndex: def __init__(self, dirIndexFile): self.d = [] self.f = [] + self.t = [] self.version = 0 self.path = None # will be a VirtualPath instance when set @@ -221,6 +222,9 @@ class DirIndex: elif tokens[0] == "f": self.f.append({ 'name': tokens[1], 'hash': tokens[2], 'size': tokens[3] }) + elif tokens[0] == "t": + self.t.append({ 'name': tokens[1], 'hash': tokens[2], 'size': tokens[3] }) + def _sanityCheck(self): if self.path is None: assert self._rawContents is not None @@ -239,6 +243,9 @@ class DirIndex: def getDirectories(self): return self.d + def getTarballs(self): + return self.t + def getFiles(self): return self.f @@ -639,6 +646,14 @@ class TerraSync: subdir['hash']) serverDirs.append(d) + for tarball in dirIndex.getTarballs(): + # Tarballs are handled the same as normal files. + f = tarball['name'] + self.processFileEntry(virtualBase / f, + join(relativeBase, f), + tarball['hash']) + serverFiles.append(f) + localFullPath = join(self.target, relativeBase) localFiles = [ f for f in listdir(localFullPath) if isfile(join(localFullPath, f)) ]