commit 127d32936fbb73772894c445dbd93d75d76669bc
parent 56c735c248bbebb5b96f9e27b87cecee79a1e94b
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Fri, 11 May 2012 12:34:00 +0200
Small adjustments in scripts, updatehash.py can now update a subdirectory.
Diffstat:
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/unhide-dotpercent.py b/unhide-dotpercent.py
@@ -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)
diff --git a/updatehash.py b/updatehash.py
@@ -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):