Menu

#4 Parameter for Update/UpdatePacked/UdateNoV2tag to decide if Backup required (default true)

closed
None
2
2015-02-14
2015-01-04
ScruffR
No

I've added some code to allow to suppress backuo creation when updating tags.
This would be nice if it found its way into thw official version too.

Discussion

  • Andrew Pearmund

    Andrew Pearmund - 2015-01-04

    That sounds useful.
    Can you send me your code changes, maybe by attaching them here?
    Cheers.

     
  • ScruffR

    ScruffR - 2015-01-04

    Sure, but I found some minor issues, I'd like to cleanup first.

     

    Last edit: ScruffR 2015-01-04
  • ScruffR

    ScruffR - 2015-01-04

    Now I think it should be save.

    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.

     

    Last edit: ScruffR 2015-01-04
    • Andrew Pearmund

      Andrew Pearmund - 2015-01-05

      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.

       
  • ScruffR

    ScruffR - 2015-01-06

    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 ;-)

     
  • ScruffR

    ScruffR - 2015-01-06

    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
  • Andrew Pearmund

    Andrew Pearmund - 2015-02-14

    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.

     
  • Andrew Pearmund

    Andrew Pearmund - 2015-02-14
    • status: open --> closed
    • assigned_to: Andrew Pearmund
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.