Skip to content

Commit d2aa001

Browse files
author
Ruksi
committed
If space check returns 0 total space for the final and dest, try installing anyway.
1 parent b15875d commit d2aa001

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

app/utils/http-helper.coffee

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,35 @@ getToDisk = (targetUrl, opts) ->
7979
diskFullMessage = (fileSize, path, pathFree) ->
8080
popup.open "disk-full", { required: bytesToMB(fileSize), diskName: checkPathEnsuringItExists(path) + ':', free: bytesToMB(pathFree) }
8181

82-
downloadStream.getFileSize().then (fileSize) ->
82+
downloadStream.getFileSize().then (fileSize1) ->
8383
if finalDir
8484
# Preference is to check disk space in both temp and final drives, but bail if not possible.
85-
diskspace.check checkPathEnsuringItExists(destPath), (err, total, free, status) =>
85+
diskspace.check checkPathEnsuringItExists(destPath), (err1, total1, free1, status1) =>
8686
diskspace.check checkPathEnsuringItExists(finalDir), (err2, total2, free2, status2) =>
8787
# The ratio 1 (package) : X (extracted package3) is the approximate ratio of the total space required.
88-
fileSize2 = fileSize * 4
89-
console.log('We have ' + free2 + ' of ' + fileSize2 + ' in final directory, ' + free + ' of ' + fileSize + ' in download directory')
90-
if fileSize2 > free2 || fileSize > free
88+
fileSize2 = fileSize1 * 4
89+
console.log "We have #{free2} of #{fileSize2} in final directory, #{free1} of #{fileSize1} in download directory"
90+
if total1 is 0 and total2 is 0
91+
console.error err1 if err1
92+
console.error err2 if err2
93+
console.log "Invalid disk space check result, trying to install anyway..."
94+
downloadStream.pipe writeStream
95+
else if fileSize2 > free2 || fileSize1 > free1
9196
# Prefer to show the stricter requirement first.
9297
if fileSize2 > free2
9398
diskFullMessage(fileSize2, finalDir, free2)
9499
else
95-
diskFullMessage(fileSize, destPath, free)
100+
diskFullMessage(fileSize1, destPath, free1)
96101
er = new Error(i18n.translate('Disk full.'))
97102
er.cancelled = true
98103
deferred.reject er
99104
require('./install-manager').cancelAll()
100105
else
101-
console.log('Need ' + fileSize2 + 'B from final directory, got ' + free2 + ', good to go!')
102-
# Get it flowing
106+
console.log "Need #{fileSize2}B from final directory, got #{free2}, good to go!"
103107
downloadStream.pipe writeStream
104108
else
105-
# Just start the download if there's no final app dir.
106109
downloadStream.pipe writeStream
107110
.fail ->
108-
# Get it flowing
109111
downloadStream.pipe writeStream
110112

111113

app/utils/http-helper.js

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)