Created
November 27, 2014 22:43
-
-
Save pke/7d95d7b13c9f37568278 to your computer and use it in GitHub Desktop.
saveAsync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
savesPending: 0 | |
saveAsync: () -> | |
#assert(!@finished, "Inspection already finished!") | |
logger.debug("Save requested (_cachedFile=#{@_cachedFile})") | |
if @saving | |
@savesPending += 1 | |
logger.debug("saveAsync: already saving, #{@savesPending} pending now") | |
return @saving | |
@saving = getCachedFile(@serialNumber) | |
.then (file) => | |
logger.debug("saveAsync: saving...") | |
@node.ownerDocument.saveToFileAsync(file) | |
.then null, (error) => | |
logger.error("saveAsync: failed with inspection #{@serialNumber} but #{@savesPending} saves pending - good luck!", error) | |
.then => | |
logger.debug("saveAsync: saved and #{@savesPending} pending") | |
@saving = null | |
if @savesPending | |
@savesPending = 0 | |
@saving = @saveAsync() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment