Onox: .... I'd like to know, would it be possible for you to post your script file somewhere so that I can see what you commented out exactly? Thanks
I disabled preallocation in my copy of Kalanyr's master script as I was downloading to a network connected NAS configured as a RAID. I commented out all lines from 1619 to 1644 AND lines 1651 to 1706 inclusive. Here's what I commented out:
# if file_sz < sz: #preallocate extra space
# if platform.system() == "Windows":
# try:
# info("increasing preallocation to '%d' bytes for '%s' " % (sz,downloading_path))
# preH = ctypes.windll.kernel32.CreateFileW(compat_downloading_path, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
# if preH==-1:
# warn("could not get filehandle")
# raise OSError()
# c_sz = ctypes.wintypes.LARGE_INTEGER(sz)
# ctypes.windll.kernel32.SetFilePointerEx(preH,c_sz,None,FILE_BEGIN)
# ctypes.windll.kernel32.SetEndOfFile(preH)
# ctypes.windll.kernel32.CloseHandle(preH)
# except:
# log_exception('')
# warn("preallocation failed")
# if preH != -1:
# info('failed - closing outstanding handle')
# ctypes.windll.kernel32.CloseHandle(preH)
# else:
# if sys.version_info[0] >= 4 or (sys.version_info[0] == 3 and sys.version_info[1] >= 3):
# info("increasing preallocation to '%d' bytes for '%s' using posix_fallocate " % (sz,downloading_path))
# with open(downloading_path, "r+b") as f:
# try:
# os.posix_fallocate(f.fileno(),0,sz)
# except:
# warn("posix preallocation failed")
AND
# if file_sz < sz: #preallocate extra space
# if platform.system() == "Windows":
# try:
# preH = -1
# info("increasing preallocation to '%d' bytes for '%s' " % (sz,downloading_path))
# preH = ctypes.windll.kernel32.CreateFileW(compat_downloading_path, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
# if preH==-1:
# warn("could not get filehandle")
# raise OSError()
# c_sz = ctypes.wintypes.LARGE_INTEGER(sz)
# ctypes.windll.kernel32.SetFilePointerEx(preH,c_sz,None,FILE_BEGIN)
# ctypes.windll.kernel32.SetEndOfFile(preH)
# ctypes.windll.kernel32.CloseHandle(preH)
# except:
# log_exception('')
# warn("preallocation failed")
# if preH != -1:
# info('failed - closing outstanding handle')
# ctypes.windll.kernel32.CloseHandle(preH)
# else:
# if sys.version_info[0] >= 4 or (sys.version_info[0] == 3 and sys.version_info[1] >= 3):
# info("increasing preallocation to '%d' bytes for '%s' using posix_fallocate " % (sz,downloading_path))
# with open(downloading_path, "r+b") as f:
# try:
# os.posix_fallocate(f.fileno(),0,sz)
# except:
# warn("posix preallocation failed")
# else:
# if platform.system() == "Windows":
# try:
# preH = -1
# info("preallocating '%d' bytes for '%s' " % (sz,downloading_path))
# preH = ctypes.windll.kernel32.CreateFileW(compat_downloading_path, GENERIC_READ | GENERIC_WRITE, 0, None, CREATE_NEW, 0, None)
# if preH==-1:
# warn("could not get filehandle")
# raise OSError()
# c_sz = ctypes.wintypes.LARGE_INTEGER(sz)
# ctypes.windll.kernel32.SetFilePointerEx(preH,c_sz,None,FILE_BEGIN)
# ctypes.windll.kernel32.SetEndOfFile(preH)
# ctypes.windll.kernel32.CloseHandle(preH)
# #DEVNULL = open(os.devnull, 'wb')
# #subprocess.call(["fsutil","file","createnew",path,str(sz)],stdout=DEVNULL,stderr=DEVNULL)
# except:
# log_exception('')
# warn("preallocation failed")
# if preH != -1:
# info('failed - closing outstanding handle')
# ctypes.windll.kernel32.CloseHandle(preH)
# else:
# if sys.version_info[0] >= 4 or (sys.version_info[0] == 3 and sys.version_info[1] >= 3):
# info("attempting preallocating '%d' bytes for '%s' using posix_fallocate " % (sz,downloading_path))
# with open(downloading_path, "wb") as f:
# try:
# os.posix_fallocate(f.fileno(),0,sz)
# except:
# warn("posix preallocation failed")