cebtenzzre / tumblr-utils

A fork of tumblr-utils with Python 3 support, bug fixes, and lots of features I found useful.
GNU General Public License v3.0
39 stars 7 forks source link

Create file if it doesn't exist and truncate existing content #20

Closed facebook-reality closed 8 months ago

facebook-reality commented 8 months ago

Addresses a couple of issues I found setting an API key:

  1. r+ doesn't create the file if it's not found. Bug can be reproduced by deleting ~/.config/tumblr-backup
  2. json.load(f) will fail raise an exception it reads an empty file, so we can give it a simple {} and then raise a more specific error if the user messes up their config
  3. Truncates files before writing. Old contents of the file will remain if the new content is shorter. Idk if OAuth keys are of a fixed length, but doesn't hurt to keep around
facebook-reality commented 8 months ago

Nevermind, fix was already pushed before I got to it. lol