Avoiding sample folder

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Avoiding sample folder

Post by desperado591 »

I tried to find an answer to my problem in the search but I am either to stupid to use the search properly or my problem has not been discussed so far :)

Is there an easy way to avoid sample folders beeing created? The sample files themselfs are deleted (or ignored), but the damn folder is still created, which keeps my SickRage from automatically delete the folder after processing the files, as the folder still has the subfolder "sample" in it.

I hope I was able to describe my problem halfway understandably with my bad English.
User avatar
safihre
Administrator
Administrator
Posts: 5712
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Avoiding sample folder

Post by safihre »

I will investigate why this happens. Should clean it up.
Are you using 5.1.3?

Sickrage is also abandoned, maybe try Sonarr?
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Re: Avoiding sample folder

Post by desperado591 »

Yes I am using 5.1.3 on my PC.

My SickRage is running on my NAS and it is a special adapted version to use the German Airdates of glotz.info, so I am really depending on SickRage :-)
User avatar
sander
Release Testers
Release Testers
Posts: 9508
Joined: January 22nd, 2008, 2:22 pm

Re: Avoiding sample folder

Post by sander »

I create a NZB file and can confirm: a "sample" directory is not removed https://raw.githubusercontent.com/sande ... 8ceff2.nzb

./sample.bin # removed by SABnzbd
./random100MB.bin
./my-date.txt
./sample # NOT removed
./sample/random100MB.bin # NOT removed



What the log shows (sabnzbd.log:10753-10759):
- sample.bin matches the sample pattern, so it's deleted (lines 10754–10755).
- sample/random100MB.bin is only tested on its own name, random100MB.bin, which doesn't match. It survives and shows up later during deobfuscation (line 10759).
- The sample folder itself is never checked or mentioned at all.

The code (/home/sander/git/sabnzbd/sabnzbd/postproc.py:1302):

for root, _dirs, files in os.walk(path): # _dirs is ignored
for file_to_match in files:
full_path = os.path.join(root, file_to_match)
if is_sample(full_path):

is_sample() (sabnzbd/misc.py:1233) applies RE_SAMPLE to os.path.basename(...) only, so the folder name sample in the path is never tested. On top of that, remove_samples only ever calls remove_file(). Even if every file inside sample/ were deleted, the empty folder would stay.

So ... also check for "sample" in directory names (but only in the downloaded / created dirs, so not in full path like /home/PeterSample/complete/blabla/linux.iso )
User avatar
safihre
Administrator
Administrator
Posts: 5712
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Avoiding sample folder

Post by safihre »

But what about this case:
./sample # NOT removed
./sample/random100MB.bin # NOT removed

Keep the sample folder?
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
sander
Release Testers
Release Testers
Posts: 9508
Joined: January 22nd, 2008, 2:22 pm

Re: Avoiding sample folder

Post by sander »

I would say: Remove any downloaded folder with "sample" in its name, so including files and subfolders in it.

It would go wrong with a Linux ISO download named "Sample", but so be it. Or ... don't delete the main folder if it has "sample" in the name, and only delete files and sub-folders. So: stuff inside.

PS: I guess the code will also delete "Sampler" stuff ... which music people might not like.
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Re: Avoiding sample folder

Post by desperado591 »

Oh, by the way: On my NAS the SABnzbd version is 4.5.4-79 and there is no problem with empty sample folders.
User avatar
sander
Release Testers
Release Testers
Posts: 9508
Joined: January 22nd, 2008, 2:22 pm

Re: Avoiding sample folder

Post by sander »

desperado591 wrote: November 2nd, 2026, 10:55 am Oh, by the way: On my NAS the SABnzbd version is 4.5.4-79 and there is no problem with empty sample folders.
Oh? I tried with 4.5.4 and I can NOT confirm:

sander@x360:~/mymount/complete/sample stuff with 4.5.4$ find
.
./random100MB.bin
./my-date.txt
./sample
./sample/random100MB.bin
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Re: Avoiding sample folder

Post by desperado591 »

[/quote]
Oh? I tried with 4.5.4 and I can NOT confirm:
[/quote]

Maybe I was not clear enough:
On my PC with 5.1.3 it does NOT delete the empty folder called sample
On my NAS with 4.5.4 it does delete any folders called sample.
User avatar
sander
Release Testers
Release Testers
Posts: 9508
Joined: January 22nd, 2008, 2:22 pm

Re: Avoiding sample folder

Post by sander »

What does your logging say about "Removing"?

Because:
My sabnzbd.log says

2026-11-02 17:43:30,604::INFO::[postproc:1215] Removing unwanted sample file /home/sander/mymount/complete/sample stuff with 4.5.4/sample.bin
2026-11-02 17:43:30,606::DEBUG::[filesystem:964] Removing dir recursively /home/sander/mymount/incomplete/sample stuff with 4.5.4

First line: good
Second line: just the whole directory because Complete is there

And result in Complete:


$ find /home/sander/mymount/complete/sample\ stuff\ with\ 4.5.4/
/home/sander/mymount/complete/sample stuff with 4.5.4/
/home/sander/mymount/complete/sample stuff with 4.5.4/random100MB.bin
/home/sander/mymount/complete/sample stuff with 4.5.4/my-date.txt
/home/sander/mymount/complete/sample stuff with 4.5.4/sample
/home/sander/mymount/complete/sample stuff with 4.5.4/sample/random100MB.bin

So ... "sample" directory still there.
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Re: Avoiding sample folder

Post by desperado591 »

So I just put a known nzb to my SAB 4.5.4 and cleaned the log. After the download was complete I found the following line in the logfile:

Removing dir /volume1/Downloads/complete/Movietitle/Sample

Movietitle was of course the name of my file which I didn´t want to expose here.
User avatar
sander
Release Testers
Release Testers
Posts: 9508
Joined: January 22nd, 2008, 2:22 pm

Re: Avoiding sample folder

Post by sander »

Interesting. Then I'm not sure about my posts anymore.
User avatar
safihre
Administrator
Administrator
Posts: 5712
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Avoiding sample folder

Post by safihre »

I think it does clean empty folders if they became empty after sample removal, but maybe that broke in some update.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
desperado591
Jr. Member
Jr. Member
Posts: 54
Joined: April 24th, 2017, 8:51 am

Re: Avoiding sample folder

Post by desperado591 »

Well, I can only say, that 4.5.4 works as it should, whereas 5.1.3 keeps the empty folder.
User avatar
safihre
Administrator
Administrator
Posts: 5712
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Avoiding sample folder

Post by safihre »

It's a bug indeed that the folder was not removed, I will fix it for 5.2.0.
Thank you for reporting!
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply