Browse Source

Mounting a netwerk drive w/ scrots after Hurr has started resulted in uploading all of em xd

Wazakindjes 4 years ago
parent
commit
1941204bf8
1 changed files with 26 additions and 7 deletions
  1. 26 7
      hurr.py

+ 26 - 7
hurr.py

@@ -13,6 +13,7 @@ import threading
 import time
 
 OLDFILES = OLDFILES_ALT = OLDFILES_DB = []
+SKIPPEM = SKIPPEM_ALT = SKIPPEM_DB = False
 AMOUNT = 0
 SSH = None
 GROWL = None
@@ -38,33 +39,51 @@ MUHCONF = {
 }
 
 def getscrots():
-	global MUHCONF
+	global MUHCONF, OLDFILES, SKIPPEM
 	p = re.compile(MUHCONF['scrotpattern'], re.I)
 	try:
-		return [f for f in os.listdir(MUHCONF['scrotdir']) if p.match(f)]
+		scrots = [f for f in os.listdir(MUHCONF['scrotdir']) if p.match(f)]
+		if SKIPPEM:
+			SKIPPEM = False
+			OLDFILES = scrots
+			return []
+		return scrots
 	except:
+		SKIPPEM = True
 		return []
 
 def getscrots_alt():
-	global MUHCONF
+	global MUHCONF, OLDFILES_ALT, SKIPPEM_ALT
 	if MUHCONF['scrotdir_alt'] == '' or MUHCONF['scrotpattern_alt'] == '':
 		return []
 
 	p = re.compile(MUHCONF['scrotpattern_alt'], re.I)
 	try:
-		return [f for f in os.listdir(MUHCONF['scrotdir_alt']) if p.match(f)]
+		scrots = [f for f in os.listdir(MUHCONF['scrotdir_alt']) if p.match(f)]
+		if SKIPPEM_ALT:
+			SKIPPEM_ALT = False
+			OLDFILES_ALT = scrots
+			return []
+		return scrots
 	except:
+		SKIPPEM_ALT = True
 		return []
 
 def getscrots_db():
-	global MUHCONF
+	global MUHCONF, OLDFILES_DB, SKIPPEM_DB
 	if MUHCONF['scrotdir_db'] == '' or MUHCONF['scrotpattern_db'] == '':
 		return []
 
 	p = re.compile(MUHCONF['scrotpattern_db'], re.I)
 	try:
-		return [f for f in os.listdir(MUHCONF['scrotdir_db']) if p.match(f)]
+		scrots = [f for f in os.listdir(MUHCONF['scrotdir_db']) if p.match(f)]
+		if SKIPPEM_DB:
+			SKIPPEM_DB = False
+			OLDFILES_DB = scrots
+			return []
+		return scrots
 	except:
+		SKIPPEM_DB = True
 		return []
 
 def growlnotif(ID, errorid=None, errormsg=None):
@@ -176,7 +195,7 @@ def runUpload(newfiles, basepath):
 			path = '%s/%s' % (basepath, file)
 			remotefile = ''.join([random.choice(string.ascii_letters + string.digits + '-_') for c in range(8)]) + (os.path.splitext(file)[1])
 			growlnotif(0)
-
+			print "Uploading %s to %s" % (path, remotefile)
 			if upload(path, remotefile) == 0:
 				growlnotif(1)