incomplete_dir_migration 647 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python3
  2. import os
  3. import sys
  4. import yaml
  5. def migrate(values):
  6. if not values["storage"]["enable_incomplete_dir"]:
  7. return values
  8. if not values["storage"]["mount_incomplete_as_separate_storage"]:
  9. return values
  10. values["storage"]["incomplete_dir_path"] = values["storage"]["downloads_incomplete"]["mount_path"]
  11. values["storage"]["downloads_incomplete"].pop("mount_path")
  12. return values
  13. if __name__ == "__main__":
  14. if len(sys.argv) != 2:
  15. exit(1)
  16. if os.path.exists(sys.argv[1]):
  17. with open(sys.argv[1], "r") as f:
  18. print(yaml.dump(migrate(yaml.safe_load(f.read()))))