I've added overloads that take a parameter bool createBackup for Update, UpdatePacked and UpdateNoV2tag in Mp3File.cs and Mp3FileData.cs.
The original parameterless overloads call the new overloads with createBackup = true to keep old code valid. FileMover.cs got some checks if bakFileInfo is (not) null depending on backup required or not.
Having looked at the code, I'm not sure what you're actually trying to achieve.
Are you trying to do the file name swapping in an unsafe manner, so it doesn't use a temp file at all while swapping a rewritten file over the old one? That's what it looks like the code is doing, There's still problems with a null backupLocation being supplied to the System.IO.File.Replace function, too.
I suspect what you're really trying to do is make sure there's no backup file left over once the rewrite has completed successfully. If so, it would be much better to let it use a temp backup file as normal, then use a parameter to arrange for it to be deleted when the operation has finished.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure, which version you looked at, because I also found the null exception.
That was one of the reasons why I deleted the original posts and uploaded the files new.
But as for your the comment about the unsafe name swapping, I'd have to have another look. I only did a quick "fix" and haven't looked as close as I probably should have done ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry it's taken so long to look at this again. I've put this into svn now.
NonNtfsReplace got split into 2 separate functions for 'with' and 'without' a permanent backup; it looked clearer that way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That sounds useful.
Can you send me your code changes, maybe by attaching them here?
Cheers.
Sure, but I found some minor issues, I'd like to cleanup first.
Last edit: ScruffR 2015-01-04
Now I think it should be save.
I've added overloads that take a parameter
bool createBackup
forUpdate
,UpdatePacked
andUpdateNoV2tag
inMp3File.cs
andMp3FileData.cs
.The original parameterless overloads call the new overloads with
createBackup = true
to keep old code valid.FileMover.cs
got some checks ifbakFileInfo
is (not)null
depending on backup required or not.Last edit: ScruffR 2015-01-04
Having looked at the code, I'm not sure what you're actually trying to achieve.
Are you trying to do the file name swapping in an unsafe manner, so it doesn't use a temp file at all while swapping a rewritten file over the old one? That's what it looks like the code is doing, There's still problems with a null backupLocation being supplied to the System.IO.File.Replace function, too.
I suspect what you're really trying to do is make sure there's no backup file left over once the rewrite has completed successfully. If so, it would be much better to let it use a temp backup file as normal, then use a parameter to arrange for it to be deleted when the operation has finished.
I'm not sure, which version you looked at, because I also found the
null
exception.That was one of the reasons why I deleted the original posts and uploaded the files new.
But as for your the comment about the unsafe name swapping, I'd have to have another look. I only did a quick "fix" and haven't looked as close as I probably should have done ;-)
OK, you are right, I missed something again :blush:
So I went with your suggestion of creating a temp backup in
NonNtfsReplace
.And I hope it's solved now.
I removed the respective wrong file in my previous post.
Last edit: ScruffR 2015-01-06
Sorry it's taken so long to look at this again. I've put this into svn now.
NonNtfsReplace got split into 2 separate functions for 'with' and 'without' a permanent backup; it looked clearer that way.