Page 1 of 1

Disable watched folder when scheduled

Posted: November 19th, 2012, 7:48 am
by personne146
Hi,
I suggest to disable watched folder scan speed when a scan is scheduled. Useful on a server (NAS), when you want use the watched folder features and allow hdd to sleep.

I made a little patch that will do the job (use the scan speed value with 0 to disable watched folder scan speed):

Code: Select all

--- SABnzbd-0.7.6_original/sabnzbd/dirscanner.py	2012-11-17 15:58:37.000000000 +0100
+++ SABnzbd-0.7.6/sabnzbd/dirscanner.py	2012-11-19 10:41:19.316211000 +0100
@@ -266,15 +266,19 @@
         self.shutdown = False
 
         while not self.shutdown:
-            # Use variable scan delay
-            x = max(self.dirscan_speed, 1)
-            while (x > 0) and not self.shutdown and not self.trigger:
-                time.sleep(1.0)
-                x = x - 1
 
-            self.trigger = False
-            if self.dirscan_speed and not self.shutdown:
-                self.scan()
+            if self.dirscan_speed = 0
+                time.sleep(60.0)
+            else:
+                # Use variable scan delay
+                x = max(self.dirscan_speed, 1)
+                while (x > 0) and not self.shutdown and not self.trigger:
+                    time.sleep(1.0)
+                    x = x - 1
+
+                self.trigger = False
+                if self.dirscan_speed and not self.shutdown:
+                    self.scan()
 
     def scan(self):
         """ Do one scan of the watched folder """
But I want to be auto-disable when a scan is scheduled (not have to put 0 in scan speed). So I read sabnzbd/scheduler.py but I don't understand when init() function is called and how to have the information of a schedule in Dirscanner class ??? .
Can someone help me ?

Re: Disable watched folder when scheduled

Posted: November 19th, 2012, 2:41 pm
by shypike
I think you're better of scheduling a "pause_all" event.
When "pause_all" is active, SABnzbd stops all disk access (including watched folder scanning).
Just stopping watched folder scanning is not enough to let the disk sleep.

Re: Disable watched folder when scheduled

Posted: November 20th, 2012, 7:38 am
by personne146
I do not want "pause_all" event, by example if there are some downloads in going.
The patch is currently running on my NAS and my disks sleep when no download is in progress (tested from SABnzbd 0.6.5 to 0.7.6).
It works, I just want a proper patch by detecting a watched folder scan in the scheduler from the Dirscanner class.

On the other hand, when the watched folder is not give, the disks are sleeping when no download in progress with another NAS.

Re: Disable watched folder when scheduled

Posted: November 20th, 2012, 3:43 pm
by shypike
What is problem with disabling the periodic scan by setting it to 0?

Re: Disable watched folder when scheduled

Posted: November 21st, 2012, 4:23 am
by personne146
To keep the same way to do like with RSS scan and to have the patch implemented in one of next SABnzbd release and finally to avoid apply patch myself each update.
I just want to give an helping hand to improve SABnzbd.

Re: Disable watched folder when scheduled

Posted: November 21st, 2012, 5:05 am
by shypike
I appreciate your wish to help.
Due to the way it's implemented, it's harder to implement this for watched folder scanning than for RSS.
The bottom line is that such a change will cost me one or two hours (there's testing too)
for a feature that I think has a very limited value. There's so much else to improve in SABnzbd.
In this case you would have to find out from the dirscanner whether a dirscan schedule is active.
It requires an ugly connection between the two (which I want to avoid) or a larger rewrite.

Re: Disable watched folder when scheduled

Posted: November 21st, 2012, 7:16 am
by personne146
That what I thought, too much work for you especially when an easy solution exists.
If I see another small features and try an implementation, posting the patch could help you ?

Re: Disable watched folder when scheduled

Posted: November 21st, 2012, 2:37 pm
by shypike
personne146 wrote:If I see another small features and try an implementation, posting the patch could help you ?
Of course, we've integrated patches in the past.
Also, your request is quite reasonable, but a little bit too tricky due to internal issues, as I have explained.