Leaves .tmp files lying around

Problem 1: When mp3tag can't write to the file (or at least, that the message it is giving me.), it leaves a .tmp file lying around.

Problem 2: I'm getting the error "cannot be opened for writing" on certain files I have, even though they clearly are writable. I know that because i checked the permissions are exactly the same as other files that it works with, and I also tried writing to the file myself, as well as copying it to another filename. So I assume "cannot be opened for writing" is actually some other problem with the file. Needs a better error message.

Problem 3: I don't know why this particular movie file can't be edited. I've got 100 files from the same source, 2 of them don't work with mp3tag. Maybe there is something wrong with the files. I can't tell what. A bit tricky to supply the file for diagnostics since it's over a gigabyte.

see e.g. here
Also, please use the search function of the forum to see reasons why files cannot be accessed - there are numerous threads about that topic. And in most cases it is a problem of the local environment.

I can't believe someone considers leaving junk files lying around is a feature. If there's really a reason for it, which I would question, then ask the user before doing it. Certainly if things failed then you already bugged the user with dialog boxes anyway, so give them the choice.

I'd consider it a feature in certain circumstances — e.g., if an error occurs between deleting the original file and moving the temporary file to the original location. This way, you wouldn't loose data and can recover from the temp file.

But from your description, it seems to not be so serious and just annoying for you. Not sure if the original file already contains the changes or not, but in either case, dealing with the temporary files is usually not an interesting task. I'm trying to do my best in making that as transparent for the user and at the same time not risking loosing data.

It's possible that both 1.) and 2.) are the result of another application blocking exclusive access to the files. Possible candidates are all kinds of sync services as Google Drive, OneDrive, ... and virus scanners — the latter are usually not so problematic. Can this be the case? Are those MP4 files?

Regarding 3.) I can't really tell from afar. Either you upload the file somewhere and I'll have a look or we leave it as it is.

Huh what? Are you implying that the user can can lose data if they don't understand the intricacies of this .tmp file? That's ridiculous. Firstly the program should make every effort to guard against that by moving the original first, (mv ABCD.mp4 ABCD-original.mp4) then opening the new file (open ABCD.mp4) before doing any work, and if anything goes wrong during this process, backing out (mv ABCD-original ABCD.mp4) and putting the file back. And if in a rare pathological case that isn't possible, the tmp file should look very close to the original so that the user has a clue that this file is important. e.g. if the original file was "ABCD.mp4" then it should be moved to "ABCD-original.mp4". Then the worst case is the file is left with a slightly odd name from which the user might deduce what happened.

So when you are working on a large library of say 25k files and are applying a change to all, mp3tag should create 25k copies? Seems far more likely for errors and disk space problems than dealing with one temp file that appears only IF something goes wrong.

Which story are you guys running with, that you need to "move a temporary file to the original location" with a brand new file, or not? If you're modifying the original in place, then are what are we even talking about? Either you need a second copy, or you don't. If you don't, then all talk about "deleting the original file" is nonsense.

I might also add, why do I need to do some search of the forums to see why the heck it failed? Either it failed because of some OS issue (permissions etc), or because the file is corrupt somehow. But when I search on this issue in the forums I find various people talking about corrupt files giving this error. Surely we can give a better error than "write failed" when the file is corrupt. I cannot believe in my case that it is an OS issue because I looked very carefully at permissions, and I tried writing the file myself. So it cannot be. If the file is corrupt, it should say so plainly.

Exactly.
You don't need a copy of the file if the modifications fit into the existing padding.
If the padding is too small, a work copy is created and later copied back to the original location.

@ohrenkino ok... and how do I lose data in either scenario requiring me to keep this tmp file?

What about other programs that access the file at the same time? You already got a list of frequent culprits. Maybe you have something even more exotic.

That depends where you look: the original file will then not show the modification.
If you don't want to repeat the whole process, then the tmp file may be a shortcut.

If another program is accessing the file, how come I can write to it? Home come a 2nd copy of the same file gives the same error? Very clearly this must be a corrupt file, and yet mp3tag gives the stupid error that "write failed".

I most certainly don't like the tone of this. Calm down.

As I said before, if the tmp file has some use, fine let the user choose to keep it. Don't just dump it there, assuming the user knows what it is.

Is this a change request?