Forums

os.replace not working

This may sound like a completely 'noob' type of issue, but it's the strangest thing. This functionality used to work just fine, but while doing some QA test scenarios today, literally none of my os.replaces are working anymore. I've even tried to simply do os.remove and another f.save(target) and nothing is working.

The scenario is that I'm allowing my users to do some in browser img editing, and when they're finished, it should simply overwrite the file with the temp file that gets uploaded to the server and that's that. When breaking down the entire process, the temp file is getting changed just fine, but any of my calls to overwrite the target path is being completely ignored. And I even simply tried to delete the file just to see what happens and that didn't do anything either. Which is VERY odd. You'd think something as straight forward as os.remove, which i have in other parts of my code would work but it doesn't.

The os.replace command IS removing the temp_file, but the target file is never updated, and, again, this used to work, but for some ungodly reason, it doesn't anymore. I've been trying to even just write janky work arounds like simply deleting the old file and saving a new one with the exact same name to no avail. The target file keeps getting reverted to it's old version, and I don't have any places that load the old version into memory. And after the os.replace, it's only some string manipulations to send back a json with the file name. No further file loading, saves, etc.

I'm wracking my brains out in this one and seeing if maybe it's something server side? Thanks in advance for any advice or help on this.

figured it out for anyone else that might run into this same issue. os.replace or PILs image.save does not like url encoded characters like '%20' for spaces and '%27' for apostrophes

Thanks for sharing!