diff --git a/config/scripts/rmf b/config/scripts/rmf index 84c6a92..099601a 100755 --- a/config/scripts/rmf +++ b/config/scripts/rmf @@ -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)