aboutsummaryrefslogtreecommitdiffstats
path: root/packages/stage-manager/files/stage-manager
diff options
context:
space:
mode:
Diffstat (limited to 'packages/stage-manager/files/stage-manager')
-rwxr-xr-xpackages/stage-manager/files/stage-manager57
1 files changed, 39 insertions, 18 deletions
diff --git a/packages/stage-manager/files/stage-manager b/packages/stage-manager/files/stage-manager
index c5b6d17a56..35453992f4 100755
--- a/packages/stage-manager/files/stage-manager
+++ b/packages/stage-manager/files/stage-manager
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# Copyright (C) 2006 Richard Purdie
+# Copyright (C) 2006-2007 Richard Purdie
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 2 as published by the Free
@@ -79,33 +79,54 @@ if __name__ == "__main__":
found = False
+ def updateCache(path, fstamp):
+ cache[path] = {}
+ cache[path]['ts'] = fstamp[stat.ST_MTIME]
+ cache[path]['size'] = fstamp[stat.ST_SIZE]
+ found = True
+
+ def copyfile(path):
+ if options.copydir:
+ copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
+ mkdirhier(os.path.split(copypath)[0])
+ os.system("cp -dp " + path + " " + copypath)
+
+ def copydir(path, fstamp):
+ if options.copydir:
+ copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
+ if os.path.islink(path):
+ os.symlink(os.readlink(path), copypath)
+ else:
+ mkdirhier(copypath)
+ os.utime(copypath, (fstamp[stat.ST_ATIME], fstamp[stat.ST_MTIME]))
+
for root, dirs, files in os.walk(options.parentdir):
for f in files:
path = os.path.join(root, f)
if not os.access(path, os.R_OK):
continue
- fstamp = os.stat(path)
+ fstamp = os.lstat(path)
if path not in cache:
print "new file %s" % path
- cache[path] = {}
- cache[path]['ts'] = fstamp[stat.ST_MTIME]
- cache[path]['size'] = fstamp[stat.ST_SIZE]
- if options.copydir:
- copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
- mkdirhier(os.path.split(copypath)[0])
- os.system("mv " + path + " " + copypath)
- found = True
+ updateCache(path, fstamp)
+ copyfile(path)
else:
if cache[path]['ts'] != fstamp[stat.ST_MTIME] or cache[path]['size'] != fstamp[stat.ST_SIZE]:
print "file %s changed" % path
- cache[path] = {}
- cache[path]['ts'] = fstamp[stat.ST_MTIME]
- cache[path]['size'] = fstamp[stat.ST_SIZE]
- if options.copydir:
- copypath = os.path.join(options.copydir, path.replace(options.parentdir, '', 1))
- mkdirhier(os.path.split(copypath)[0])
- os.system("mv " + path + " " + copypath)
- found = True
+ updateCache(path, fstamp)
+ copyfile(path)
+ for d in dirs:
+ path = os.path.join(root, d)
+ fstamp = os.lstat(path)
+ if path not in cache:
+ print "new dir %s" % path
+ updateCache(path, fstamp)
+ copydir(path, fstamp)
+ else:
+ if cache[path]['ts'] != fstamp[stat.ST_MTIME]:
+ print "dir %s changed" % path
+ updateCache(path, fstamp)
+ copydir(path, fstamp)
if options.update:
print "Updating"