diff --git a/epicyon.py b/epicyon.py index 96b87396e..59c0e2cd5 100644 --- a/epicyon.py +++ b/epicyon.py @@ -326,12 +326,12 @@ parser.add_argument('--image', '--background', dest='backgroundImage', parser.add_argument('--archive', dest='archive', type=str, default=None, help='Archive old files to the given directory') -parser.add_argument('--archiveweeks', dest='archiveWeeks', type=str, - default=None, +parser.add_argument('--archiveweeks', dest='archiveWeeks', type=int, + default=4, help='Specify the number of weeks after which ' + - 'data will be archived') -parser.add_argument('--maxposts', dest='archiveMaxPosts', type=str, - default=None, + 'media will be archived') +parser.add_argument('--maxposts', dest='archiveMaxPosts', type=int, + default=32000, help='Maximum number of posts in in/outbox') parser.add_argument('--minimumvotes', dest='minimumvotes', type=int, default=1, @@ -1574,13 +1574,6 @@ if args.changepassword: print('Passwords file not found') sys.exit() -archiveWeeks = 4 -if args.archiveWeeks: - archiveWeeks = args.archiveWeeks -archiveMaxPosts = 32000 -if args.archiveMaxPosts: - archiveMaxPosts = args.archiveMaxPosts - if args.archive: if args.archive.lower().endswith('null') or \ args.archive.lower().endswith('delete') or \ @@ -1589,8 +1582,8 @@ if args.archive: print('Archiving with deletion of old posts...') else: print('Archiving to ' + args.archive + '...') - archiveMedia(baseDir, args.archive, archiveWeeks) - archivePosts(baseDir, httpPrefix, args.archive, {}, archiveMaxPosts) + archiveMedia(baseDir, args.archive, args.archiveWeeks) + archivePosts(baseDir, httpPrefix, args.archive, {}, args.archiveMaxPosts) print('Archiving complete') sys.exit() diff --git a/media.py b/media.py index 25532ce22..2163820d8 100644 --- a/media.py +++ b/media.py @@ -199,9 +199,12 @@ def attachMedia(baseDir: str, httpPrefix: str, domain: str, port: int, def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks=4) -> None: """Any media older than the given number of weeks gets archived """ + if maxWeeks == 0: + return + currTime = datetime.datetime.utcnow() weeksSinceEpoch = int((currTime - datetime.datetime(1970, 1, 1)).days/7) - minWeek = weeksSinceEpoch-maxWeeks + minWeek = weeksSinceEpoch - maxWeeks if archiveDirectory: if not os.path.isdir(archiveDirectory): diff --git a/posts.py b/posts.py index 67c5a56a5..359536abe 100644 --- a/posts.py +++ b/posts.py @@ -3144,9 +3144,13 @@ def archivePosts(baseDir: str, httpPrefix: str, archiveDir: str, maxPostsInBox=32000) -> None: """Archives posts for all accounts """ + if maxPostsInBox == 0: + return + if archiveDir: if not os.path.isdir(archiveDir): os.mkdir(archiveDir) + if archiveDir: if not os.path.isdir(archiveDir + '/accounts'): os.mkdir(archiveDir + '/accounts')