Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix downloading corrupt files

  • Loading branch information...
commit 45d55e164f6ccb430416ad35d32c7972296987f8 1 parent 4d44af0
@popovb authored
Showing with 29 additions and 2 deletions.
  1. +29 −2 flibaloader/Downloader.py
View
31 flibaloader/Downloader.py
@@ -19,6 +19,7 @@
import os
import sys
import urllib2
+import zipfile
BASE_ADDRESS1 = 'http://www.flibusta.net/daily/'
BASE_ADDRESS2 = 'http://proxy.flibusta.net/daily/'
@@ -42,6 +43,16 @@ def getFileContent (FileName):
rp = _getX (BASE_ADDRESS2 + FileName)
return rp
+
+def testZipFile (filename):
+ try:
+ file = zipfile.ZipFile (filename, 'r');
+
+ except:
+ return False
+ return True
+
+
def downloadFiles (filelist, download_dir):
for fn in filelist:
remotename = os.path.join (BASE_ADDRESS1, fn)
@@ -77,8 +88,24 @@ def downloadFiles (filelist, download_dir):
fh.close ()
return 5;
###
-
- print "OK"
+
sys.stdout.flush ()
fh.close ()
+
+ if testZipFile (myfilename):
+ print "OK"
+
+ else:
+ print "CORRUPT"
+ os.remove (myfilename)
return 0
+
+
+if __name__ == '__main__':
+
+ if testZipFile (sys.argv[1]):
+ print "OK"
+
+ else:
+ print "ERROR"
+ os.remove (sys.argv[1])
Please sign in to comment.
Something went wrong with that request. Please try again.