"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/checkDB.py" between
Tardis-1.1.5.tar.gz and Tardis-1.2.1.tar.gz

About: Tardis is a system for making encrypted, incremental backups of filesystems.

checkDB.py  (Tardis-1.1.5):checkDB.py  (Tardis-1.2.1)
skipping to change at line 36 skipping to change at line 36
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
import os, os.path import os, os.path
import sys import sys
import sqlite3 import sqlite3
import gettext import gettext
import glob
from Tardis import CacheDir
from Tardis import Util from Tardis import Util
def hexcount(lower, upper, digits): def hexcount(lower, upper, digits):
fmt = "%0" + str(digits) + "x" fmt = "%0" + str(digits) + "x"
for i in range(lower, upper): for i in range(lower, upper):
out = fmt % (i) out = fmt % (i)
yield out yield out
def getdbfiles(conn, prefix): def getdbfiles(conn, prefix):
prefix += "%" prefix += "%"
skipping to change at line 62 skipping to change at line 64
break break
ret.update([i[0] for i in batch]) ret.update([i[0] for i in batch])
return ret return ret
def hasExt(x): def hasExt(x):
(_, e) = os.path.splitext(x) (_, e) = os.path.splitext(x)
return (e is not '' and e is not None) return (e is not '' and e is not None)
def main(): def main():
d = sys.argv[1] d = sys.argv[1]
cd = CacheDir.CacheDir(d, create=False)
db = os.path.join(d, "tardis.db") db = os.path.join(d, "tardis.db")
print("Opening DB: " + db) print("Opening DB: " + db)
conn = sqlite3.connect(db) conn = sqlite3.connect(db)
print("Connected") print("Connected")
missingData = set() missingData = set()
unreferenced = set() unreferenced = set()
for i in hexcount(0, 256, 2): for i in hexcount(0, 16 ** int(cd.partsize), int(cd.partsize)):
print("Starting: ", i) print(f"Starting: {i} ", end='')
# Get all the files which start with i # Get all the files which start with i
dbfiles = getdbfiles(conn, i) dbfiles = getdbfiles(conn, i)
alldatafiles = set() alldatafiles = set()
# Grab each subdirectory, # Grab each subdirectory,
for j in hexcount(0, 256, 2):
path = os.path.join(d, i, j) path = os.path.join(d, i)
try: try:
if os.path.isdir(path): if os.path.isdir(path):
contents = os.listdir(path) pattern = ('?' * int(cd.partsize) + os.sep) * (int(cd.parts)-1)
metafiles = set(filter(hasExt, contents)) + "*"
datafiles = set([x for x in contents if not hasExt(x)]) pattern = os.path.join(d, i, pattern)
#print(pattern)
alldatafiles.update(datafiles)
# contents = os.listdir(path)
#print path, " :: ", len(contents), len(metafiles), len(data contents = list(map(lambda x: os.path.basename(x), glob.glob(pat
files), " :: ", len(dbfiles) tern, recursive=True)))
# Process the signature files # print(contents)
for f in metafiles: print(f"{len(contents)} files")
(data, _) = os.path.splitext(f) metafiles = set(filter(hasExt, contents))
if not data in datafiles: datafiles = set([x for x in contents if not hasExt(x)])
print("{} without matching data file".format(f))
except Exception as e: alldatafiles.update(datafiles)
print("Caught exception proecssing directory {}".format(path))
#print path, " :: ", len(contents), len(metafiles), len(datafile
s), " :: ", len(dbfiles)
# Process the signature files
for f in metafiles:
(data, _) = os.path.splitext(f)
if not data in datafiles:
print("{} without matching data file".format(f))
else:
print()
except Exception as e:
print("Caught exception proecssing directory {}: {}".format(path), e
)
# Find missing data files # Find missing data files
missing = dbfiles.difference(alldatafiles) missing = dbfiles.difference(alldatafiles)
missingData.update(missing) missingData.update(missing)
for i in missing: for i in missing:
print("Missing data files {}".format(i)) print("Missing data file {}".format(i))
# Find files which aren't in the DB # Find files which aren't in the DB
unref = alldatafiles.difference(dbfiles) unref = alldatafiles.difference(dbfiles)
unreferenced.update(unref) unreferenced.update(unref)
for i in unref: for i in unref:
print("Unreferenced data file: {}".format(i)) print("Unreferenced data file: {}".format(i))
conn.close() conn.close()
if __name__ == "__main__": if __name__ == "__main__":
 End of changes. 6 change blocks. 
22 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)