Skip to content
Snippets Groups Projects
Commit d23a2d93 authored by ale's avatar ale
Browse files

add a --apply option (default to dry run, no files removed) for the deduper

parent 6d0d09b6
Branches
No related tags found
No related merge requests found
......@@ -51,10 +51,11 @@ class DeDuper(object):
if title: data["track"] = title
return data
def dedupe(self):
def dedupe(self, dry_run=True):
self._ingest()
self._scan_for_dupes()
self._cleanup()
if not dry_run:
self._cleanup()
def _ingest(self):
self.codes = {}
......@@ -220,15 +221,16 @@ class DeDuper(object):
Session.commit()
def run_deduper(db_url):
def run_deduper(db_url, dry_run):
init_db(db_url)
dup = DeDuper()
dup.dedupe()
dup.dedupe(dry_run)
def main():
parser = optparse.OptionParser()
parser.add_option('--db_url')
parser.add_option('--apply', action='store_true')
daemonize.add_standard_options(parser)
utils.read_config_defaults(
parser, os.getenv('DJRANDOM_CONF', '/etc/djrandom.conf'))
......@@ -239,7 +241,7 @@ def main():
parser.error('Too many arguments')
daemonize.daemonize(opts, run_deduper,
(opts.db_url,))
(opts.db_url, not opts.apply))
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment