[F] Undo after last action changes directory names

Prompted by an earlier thread on Ctrl+Z actions.

Using Ctrl+Z to "Undo last action(s)" will cause an application crash if the last action(s) changed a directory name.

Memory dump attached.

Mp3tag.dmp (67.2 KB)

Chris Hirst, please provide an example of your test case.

I did a quick test with one subfolder, which contains some mp3 and other files.
I used the action "Format value" on the pseudo tag field _DIRECTORY in order to rename the current folder name.
Mp3tag did the "moving process" perfectly without error.
Using "Undo [Ctrl+Z]" Mp3tag reversed the previous processing without any fault.

DD.20140128.1320.CET

I'll be more specific (as I really should have been in the first place)

This occurs after a script action group that runs conditional appends to the directory name, and this is likely to be an "edge use case"

[#65]
T=5
F=_FILENAME
1=$ifgreater(%track%,0,%track%$if(%vinyltrack%,' - '%vinyltrack%,) - %title%,%title%)

[#66]
T=5
F=ALBUMARTIST
1=$iflonger(%albumartist%,0,%albumartist%,%artist%)

[#67]
T=5
F=_DIRECTORY
1=%albumartist% - [$trim(%year%)][-%order%][ - %album%]

[#68]
T=5
F=_DIRECTORY
1=%_directory%[ - $trim(%edition%)]

[#69]
T=5
F=_DIRECTORY
1=%_directory%$ifgreater(%volume%,0, - Vol. %volume%,)$ifgreater(%discnumber%,0, - Disc %discnumber%,)

[#70]
T=5
F=_DIRECTORY
1=%_directory%[ - %reissued%'-Reissue']

[#71]
T=5
F=_DIRECTORY
1=%_directory%[ - %remastered%'-Remaster.']

[#72]
T=5
F=_DIRECTORY
1=%_directory%[ - %recordingdate%]

[#73]
T=5
F=_DIRECTORY
1=%_directory%[ - '('%venue%')']

[#74]
T=5
F=_DIRECTORY
1=%_directory%[ - %discname%]

[#75]
T=5
F=_DIRECTORY
1=$regexp(%_directory%,((\\\\s-\\\\s){2}), - )

There is more to the group but from testing it only seems to be once the directory naming routines have started that it will crash on attempting an 'undo', as I have a group that does the same tag formatting (not shown) and sets the filename, that will 'undo'.

In all reality, I would not expect any application to track and be able to "undo" all of those actions, maybe just handle it better and/or fail gracefully.

Yes, I can reproduce the "unexpected error" using your mta code.

Because your mta script changes the directory name many times, I am unsure whether Mp3tag does it in reality also many times for each code step.
This would include that Mp3tag has to "move" the entire folder (many times - 1) unnecessary.
Maybe Mp3tag "virtually sums up" all folder name changes and does the real "move" only once at end of the mta code, who knows it for sure?

So I modified the mta file to "move" the current folder only once.

[#0]
T=5
F=ALBUMARTIST
1=$iflonger(%albumartist%,0,%albumartist%,%artist%)

[#1]
T=5
F=TMP_DIR
1=%albumartist%[' - '$trim(%year%)]['-'%order%][' - '%album%]

[#2]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - '$trim(%edition%)]

[#3]
T=5
F=TMP_DIR
1=%TMP_DIR%$ifgreater(%volume%,0,' - Vol. '%volume%,)$ifgreater(%discnumber%,0,' - Disc '%discnumber%,)

[#4]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - '%reissued%'-Reissue']

[#5]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - '%remastered%'-Remaster']

[#6]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - '%recordingdate%]

[#7]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - ('%venue%')']

[#8]
T=5
F=TMP_DIR
1=%TMP_DIR%[' - '%discname%]

[#9]
T=5
F=TMP_DIR
1=$regexp(%TMP_DIR%,'(\\\\s-\\\\s)\\\\1+',' - ')

[#10]
T=5
F=TMP_FN
1=$ifgreater(%track%,0,%track%[' - '%vinyltrack%]' - '%title%,%title%)

[#11]
T=5
F=_DIRECTORY
1=$validate(%TMP_DIR%,'_')

[#12]
T=5
F=_FILENAME
1=$validate(%TMP_FN%,'_')

[#13]
T=9
F=TMP_DIR;TMP_FN

A first trial gives no error, when immediately pressed [Ctrl+Z] after executing the mta file!
While a following trial the unexpected error occurred again.

So what happened in the file system?
While undoing Mp3tag did recreate the formerly removed folder and has moved the one file, which was selected in the list view.
All other files were left in the new folder, which has been created while runtime of the mta file.
Does the unexpected error reside in this Mp3tag internal process step?

Maybe the invocation of both file system related operations, on _DIRECTORY and on _FILENAME, should be avoided in one mta.
Split the mta file in two parts, one for the folder name manipulation, and one for the filename manipulation, and report what happens.

DD.20140128.1733.CET

Cheers! That's saved me a bit of coding, concatenating the directory variables was my next target after I've got the directory and album tag parsing done and dusted. :slight_smile:

The crash conditions are when running the MTA on more than one file in the same directory.

Ctrl+Z will undo the last directory rename and file move then bomb out.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.