arfoll / unrarall

bash script to unrar everything and cleanup in a given directory
GNU General Public License v3.0
261 stars 68 forks source link

Cleanup after unsuccessfull extraction (due to missing/wrong archive password) #12

Closed giuspe closed 10 years ago

giuspe commented 10 years ago

Hi,

when I use 'all' as cleanup hook and I skip some archive due to missing (or forgotten...) password the archive gets cleaned as well, and deleted.

would be useful some option to skip file cleanup when password is not given/wrong.

thanks for all your work!

delcypher commented 10 years ago

Oh that's a nasty bug. Thanks for reporting.

Could you provide us with a small example rar file with password protection ( and tell us what the password is too ) so we can do some testing?

How were you skipping the rar file? Does unrar ( or p7zip ) just exit when you enter the wrong password or did you hit CTRL+C?

giuspe commented 10 years ago

Hi,

and thanks for you reply.

I attach a small rar file with password (pass).

I was using unrar method to decompress, and skipped the file (prompting for password) just ENTERing (empty password).

the process didn't exit, just failed extracting and went on normally;

I attach some logs (as an example)

$ unrarall --full-path --clean=all --force --verbose ./ Detecting clean up hooks... _Found unrarall-clean-coversfolders Found unrarall-clean-nfo _Found unrarall-clean-osxjunk Found unrarall-clean-rar _Found unrarall-clean-samplefolders _Found unrarall-clean-samplevideos _Found unrarall-clean-windowsjunk Using virtual clean-up hook all Looking for unrar...found Using "unrar" to extract rar files Working over directory "./" Extracting (x) "./wpass.rar"... UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal

Extracting from wpass.rar

Enter password (will not be echoed) for Mario.ogg: [ENTER here]

Enter password (will not be echoed) for Mario Castle.ogg: *[ENTER here]*

Enter password (will not be echoed) for Mario Course.ogg: *[ENTER here]*

No files to extract failed (forced) _Running hooks...coversfolders Removing all Covers/ folders find: warning: you have specified the -depth option after a non-option argument -type, but options are not positional (-depth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

nfo Deleting wpass.nfo _osx_junk Hook osx_junk: No .DSStore file/folder found. rar Deleting wpass rar files... removed './wpass.rar' _samplefolders Removing all Sample/ folders _samplevideos Removing video files with "sample" prefix _windows_junk Hook windowsjunk: No Thumbs.db file/folder found. Finished running hooks no rar files extracted

hope that helps, and thanks again.

giuseppe

2014-02-06 10:20 GMT+01:00 Dan Liew notifications@github.com:

Oh that's a nasty bug. Thanks for reporting.

Could you provide us with a small example rar file with password protection ( and tell us what the password is too ) so we can do some testing?

How were you skipping the rar file? Does unrar ( or p7zip ) just exit when you enter the wrong password or did you hit CTRL+C?

Reply to this email directly or view it on GitHubhttps://github.com/arfoll/unrarall/issues/12#issuecomment-34305099 .


giuspe@gmail.com VOIP# 02 320624698

arfoll commented 10 years ago

Hey - like Dan says, that's not good :(.

Seems that unrar must be returning an exit code that's ok (that's basically how we tell between good/bad extraction).

You've got an older version of unrar there, I'm on unrar 5.01 but honestly I've never tried passworded archives...

I can't see the file could you email it to us?

Thanks!

giuspe commented 10 years ago

Hi there,

I'm no UNRAR 4.20 freeware, installed via Ubuntu repositories.

I'm attaching the file, let me know if you get it.

giuseppe

2014-02-06 10:37 GMT+01:00 Brendan Le Foll notifications@github.com:

Hey - like Dan says, that's not good :(.

Seems that unrar must be returning an exit code that's ok (that's basically how we tell between good/bad extraction).

You've got an older version of unrar there, I'm on unrar 5.01 but honestly I've never tried passworded archives...

I can't see the file could you email it to us?

Thanks!

Reply to this email directly or view it on GitHubhttps://github.com/arfoll/unrarall/issues/12#issuecomment-34306215 .


giuspe@gmail.com VOIP# 02 320624698

arfoll commented 10 years ago

I think attachments get lost on the way to github can you just mail it to brendan@fridu.net?

arfoll commented 10 years ago

Ok so I've built a unrar 4.20 and the behaviour of the return code is the same, It seems this must be something to do when there is an archive in the same dir that does succeed after the first one fails?

Can you confirm you get this as well if you just have one archive in the dir?

brendan@jupiter /tmp/test % unrarall -v --clean=all .           
Detecting clean up hooks...
Found unrarall-clean-covers_folders
Found unrarall-clean-nfo
Found unrarall-clean-osx_junk
Found unrarall-clean-rar
Found unrarall-clean-sample_folders
Found unrarall-clean-sample_videos
Found unrarall-clean-windows_junk
Using virtual clean-up hook all
Looking for unrar...found
Using "unrar" to extract rar files
Working over directory "/tmp/test"
Extracting (e) "/tmp/test/wpass.rar"...
UNRAR 4.20 freeware      Copyright (c) 1993-2012 Alexander Roshal

Extracting from wpass.rar

Enter password (will not be echoed) for Mario.ogg: 

Extracting  Mario.ogg                                                 36%
CRC failed in the encrypted file Mario.ogg. Corrupt file or wrong password.
Mario Castle.ogg - use current password ? [Y]es, [N]o, [A]ll n

Enter password (will not be echoed) for Mario Castle.ogg: 

Extracting  Mario Castle.ogg                                          42%
CRC failed in the encrypted file Mario Castle.ogg. Corrupt file or wrong password.
Mario Course.ogg - use current password ? [Y]es, [N]o, [A]ll N

Enter password (will not be echoed) for Mario Course.ogg: 

Total errors: 3
failed
Couldn't do requested clean because unrar extracted unsuccessfully. Use --force to override this behaviour
no rar files extracted

I will try have a better look sometime later this week.

giuspe commented 10 years ago

Hi,

yes, positive: I ran this last test with just one archive (the failing password one)

I'm on a ubuntu 13.10 system, zsh shell.

.g

2014-02-06 11:07 GMT+01:00 Brendan Le Foll notifications@github.com:

Ok so I've built a unrar 4.20 and the behaviour of the return code is the same, It seems this must be something to do when there is an archive in the same dir that does succeed after the first one fails?

Can you confirm you get this as well if you just have one archive in the dir?

brendan@jupiter /tmp/test % unrarall -v --clean=all . Detecting clean up hooks... Found unrarall-clean-covers_folders Found unrarall-clean-nfo Found unrarall-clean-osx_junk Found unrarall-clean-rar Found unrarall-clean-sample_folders Found unrarall-clean-sample_videos Found unrarall-clean-windows_junk Using virtual clean-up hook all Looking for unrar...found Using "unrar" to extract rar files Working over directory "/tmp/test" Extracting (e) "/tmp/test/wpass.rar"... UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal

Extracting from wpass.rar

Enter password (will not be echoed) for Mario.ogg:

Extracting Mario.ogg 36% CRC failed in the encrypted file Mario.ogg. Corrupt file or wrong password. Mario Castle.ogg - use current password ? [Y]es, [N]o, [A]ll n

Enter password (will not be echoed) for Mario Castle.ogg:

Extracting Mario Castle.ogg 42% CRC failed in the encrypted file Mario Castle.ogg. Corrupt file or wrong password. Mario Course.ogg - use current password ? [Y]es, [N]o, [A]ll N

Enter password (will not be echoed) for Mario Course.ogg:

Total errors: 3 failed Couldn't do requested clean because unrar extracted unsuccessfully. Use --force to override this behaviour no rar files extracted

I will try have a better look sometime later this week.

Reply to this email directly or view it on GitHubhttps://github.com/arfoll/unrarall/issues/12#issuecomment-34308409 .


giuspe@gmail.com VOIP# 02 320624698

delcypher commented 10 years ago

@giuspe In one of your earlier posts when you show a log, why are you using the --force flag?

$ unrarall --full-path --clean=all --force --verbose ./*

Using the --force flag will run the clean hooks even if extraction fails. If you want the clean hooks to not run when you do not enter a password you should not use the --force flag (in fact using the --force flag is almost always a bad idea).

giuspe commented 10 years ago

hi Dan,

...oh, I see... :-\

sorry for the false alarm, I guess it was just a RTFM issue after all... sorry!

(and thanks, by the way...)

have a good day,

.g

2014-02-06 12:18 GMT+01:00 Dan Liew notifications@github.com:

@giuspe https://github.com/giuspe In one of your earlier posts when you show a log, why are you using the --force flag?

$ unrarall --full-path --clean=all --force --verbose ./*

Using the --force flag will run the clean hooks even if extraction fails. If you want the clean hooks to not run when you do not enter a password you should not use the --force flag (in fact using the --force flag is almost always a bad idea).

Reply to this email directly or view it on GitHubhttps://github.com/arfoll/unrarall/issues/12#issuecomment-34313743 .


giuspe@gmail.com VOIP# 02 320624698

arfoll commented 10 years ago

Nice catch Dan! Saved me a big of head scratching later!

The --force flag is a hack I did ages ago to get rid of some broken files but yeah it's not usually a good idea to use it and definitely not a good idea on a dir with lots of files!