Browse Source

rmfMostRecent

master
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():
345 345
                 table.set(x, y+1, features[featureName][y])
346 346
         table.print()
347 347
 
348
-    def decideAction(self):
348
+    def decideAction(self, mostRecent=False):
349 349
         # TODO More arguments for choosing
350 350
         reason = "undecided"
351 351
         self.action = None
@@ -357,6 +357,16 @@ class DatabaseFile():
357 357
             if len(features) == 1:
358 358
                 reason = "same files"
359 359
                 self.action = 0
360
+            elif 'st_mtime' in features and mostRecent:
361
+                recentTime = features['st_mtime'][0]
362
+                recentIndex = 0
363
+                for index, time in enumerate(features['st_mtime']):
364
+                    if time > recentTime:
365
+                        recentTime = time
366
+                        recentIndex = 0
367
+                self.action = recentIndex
368
+                reason = "most recent"
369
+
360 370
         if self.action is None:
361 371
             log.warning(
362 372
                 f"{self.root}/{self.filename}: skip, cause: {reason}")
@@ -390,6 +400,8 @@ if __name__ == "__main__":
390 400
                         nargs='?', help='Directory to analyse')
391 401
     parser.add_argument('-d', '--database',
392 402
                         help='Database path for file informations')
403
+    parser.add_argument('-r', '--most-recent', action='store_true',
404
+                        help='Always keep the most recent version')
393 405
     parser.add_argument('-e', '--execute', action='store_true',
394 406
                         help='Really apply changes')
395 407
     parser.add_argument('-p', '--print', action='store_true',
@@ -436,4 +448,4 @@ if __name__ == "__main__":
436 448
     if args.print:
437 449
         database.printDifferences()
438 450
     else:
439
-        database.takeAction(execute=args.execute)
451
+        database.takeAction(mostRecent=args.most_recent, execute=args.execute)

Loading…
Cancel
Save