Python: Can't delete file from Dropbox?
I use Editorial exclusively with Dropbox synced files. Having found no way to programatically rename a document, I've created a workflow that just makes a named copy and deletes the original. It's something along these lines:
- Store current filename with editor.get_path()
- Set a variable with the first line of text
- Set a variable with the full contents of the file
- Create a new document, filled with the values of the previous variables
- Delete the previous file with os.remove()
The problem is that when the workflow is run, a "renamed" file is created, but the original is only emptied down to zero bytes; I still see it in the file list.
I tested the workflow with a local file and everything worked fine.
What's wrong with Dropbox? Is it a bug? Is there a way around it?
If you want to manage files that are in Dropbox, you'll have to do so using the Dropbox SDK. Editorial's sync mechanism is not prepared for changes "behind its back", so you basically shouldn't ever touch synced files directly.
Would "sync with dropbox" in the process not work?
create new document, delete old document, sync with dropbox, refresh view?
@RNC No, that wouldn't work. The sync engine needs to be informed that the file was intentionally deleted (and that's not supported programmatically), otherwise, it would re-download a fresh copy...