Small adjustments in scripts, updatehash.py can now update a subdirectory.
This commit is contained in:
parent
56c735c248
commit
127d32936f
|
@ -7,16 +7,17 @@ def walk(path):
|
|||
#print >> sys.stderr, path
|
||||
for f in os.listdir(path):
|
||||
fpath = os.path.join(path, f)
|
||||
if os.path.isdir(fpath) and not os.path.islink(fpath):
|
||||
walk(fpath)
|
||||
if f[0:2] == ".%":
|
||||
ff = f
|
||||
while ff[0:2] == ".%":
|
||||
ff = ff[2:]
|
||||
dest = os.path.join(path, ff)
|
||||
if not os.path.exists(dest):
|
||||
print "i-have-moved -i '%s' '%s'" % (fpath.replace("'", "'\\''"), dest.replace("'", "'\\''"))
|
||||
print "i-have-moved -i -- '%s' '%s'" % (fpath.replace("'", "'\\''"), dest.replace("'", "'\\''"))
|
||||
os.rename(fpath, dest)
|
||||
if os.path.isdir(fpath) and not os.path.islink(fpath):
|
||||
walk(fpath)
|
||||
|
||||
def help():
|
||||
print 'Usage : %s directory' % sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
|
|
@ -66,8 +66,13 @@ def update(connection,cursor,path):
|
|||
connection.commit()
|
||||
print "commit!"
|
||||
print "cleaning up..."
|
||||
cursor.execute("insert into removedfiles(rmtimestamp,tag,timestamp,path,md5,sha1,mtime,size) select ?,tag,timestamp,path,md5,sha1,mtime,size from files where path not in newfiles", (timestamp,))
|
||||
cursor.execute("delete from files where path not in (select path from newfiles)")
|
||||
cursor.execute("create temp table deletedfiles(path)")
|
||||
cursor.execute("create index i_deletedfiles_path on deletedfiles(path)")
|
||||
likepath=('' + path).replace('%', '%%') + '%';
|
||||
cursor.execute("insert into deletedfiles(path) select path from files where path like ?", (likepath,));
|
||||
cursor.execute("delete from deletedfiles where path in newfiles");
|
||||
cursor.execute("insert into removedfiles(rmtimestamp,tag,timestamp,path,md5,sha1,mtime,size) select ?,tag,timestamp,path,md5,sha1,mtime,size from files where path in deletedfiles", (timestamp,))
|
||||
cursor.execute("delete from files where path in deletedfiles")
|
||||
connection.commit()
|
||||
|
||||
def walk(db,path):
|
||||
|
|
Loading…
Reference in New Issue
Block a user