Browse Source

rmfMostRecent

master
Geoffrey Frogeye 5 months ago
parent
commit
30362018b2
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      config/scripts/rmf

+ 14
- 2
config/scripts/rmf View File

@@ -345,7 +345,7 @@ class DatabaseFile():
table.set(x, y+1, features[featureName][y])
table.print()

def decideAction(self):
def decideAction(self, mostRecent=False):
# TODO More arguments for choosing
reason = "undecided"
self.action = None
@@ -357,6 +357,16 @@ class DatabaseFile():
if len(features) == 1:
reason = "same files"
self.action = 0
elif 'st_mtime' in features and mostRecent:
recentTime = features['st_mtime'][0]
recentIndex = 0
for index, time in enumerate(features['st_mtime']):
if time > recentTime:
recentTime = time
recentIndex = 0
self.action = recentIndex
reason = "most recent"

if self.action is None:
log.warning(
f"{self.root}/{self.filename}: skip, cause: {reason}")
@@ -390,6 +400,8 @@ if __name__ == "__main__":
nargs='?', help='Directory to analyse')
parser.add_argument('-d', '--database',
help='Database path for file informations')
parser.add_argument('-r', '--most-recent', action='store_true',
help='Always keep the most recent version')
parser.add_argument('-e', '--execute', action='store_true',
help='Really apply changes')
parser.add_argument('-p', '--print', action='store_true',
@@ -436,4 +448,4 @@ if __name__ == "__main__":
if args.print:
database.printDifferences()
else:
database.takeAction(execute=args.execute)
database.takeAction(mostRecent=args.most_recent, execute=args.execute)

Loading…
Cancel
Save