rmfMostRecent
This commit is contained in:
parent
e76aaec03c
commit
90d5cd4d1f
|
@ -345,7 +345,7 @@ class DatabaseFile():
|
||||||
table.set(x, y+1, features[featureName][y])
|
table.set(x, y+1, features[featureName][y])
|
||||||
table.print()
|
table.print()
|
||||||
|
|
||||||
def decideAction(self):
|
def decideAction(self, mostRecent=False):
|
||||||
# TODO More arguments for choosing
|
# TODO More arguments for choosing
|
||||||
reason = "undecided"
|
reason = "undecided"
|
||||||
self.action = None
|
self.action = None
|
||||||
|
@ -357,6 +357,16 @@ class DatabaseFile():
|
||||||
if len(features) == 1:
|
if len(features) == 1:
|
||||||
reason = "same files"
|
reason = "same files"
|
||||||
self.action = 0
|
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:
|
if self.action is None:
|
||||||
log.warning(
|
log.warning(
|
||||||
f"{self.root}/{self.filename}: skip, cause: {reason}")
|
f"{self.root}/{self.filename}: skip, cause: {reason}")
|
||||||
|
@ -390,6 +400,8 @@ if __name__ == "__main__":
|
||||||
nargs='?', help='Directory to analyse')
|
nargs='?', help='Directory to analyse')
|
||||||
parser.add_argument('-d', '--database',
|
parser.add_argument('-d', '--database',
|
||||||
help='Database path for file informations')
|
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',
|
parser.add_argument('-e', '--execute', action='store_true',
|
||||||
help='Really apply changes')
|
help='Really apply changes')
|
||||||
parser.add_argument('-p', '--print', action='store_true',
|
parser.add_argument('-p', '--print', action='store_true',
|
||||||
|
@ -436,4 +448,4 @@ if __name__ == "__main__":
|
||||||
if args.print:
|
if args.print:
|
||||||
database.printDifferences()
|
database.printDifferences()
|
||||||
else:
|
else:
|
||||||
database.takeAction(execute=args.execute)
|
database.takeAction(mostRecent=args.most_recent, execute=args.execute)
|
||||||
|
|
Loading…
Reference in a new issue