Skip to content

Commit

Permalink
If a write fails, don't assume it's a conflict.
Browse files Browse the repository at this point in the history
A failed write attempts to reload the repo, causing an error if another is
already running. This change helps do less unnecessary reloads.
  • Loading branch information
izak committed Mar 4, 2014
1 parent 3a5e1cc commit 8acc315
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions scripts/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,23 @@ define [
promise.resolve(val)
)
.fail (err) =>
# Probably a conflict because of a remote change.
# Possibly a conflict because of a remote change.
# Resolve the changes and save again
#
# Reload all the models (merging local changes along the way)
# and, at the same time get the new lastSeenSha
remoteUpdater.pollUpdates().then () =>
# Probably a patch/cache problem.
# Clear the cache and try again
session.getClient().clearCache?()
writeFiles(models, commitText)
.fail((err) => promise.reject(err))
.done (val) => promise.resolve(val)
# TODO: Not sure what code gihub sends back for a conflict, but it's
# gotta be one of these.
if err.status == 422 or err.status == 409
remoteUpdater.pollUpdates().then () =>
# Probably a patch/cache problem.
# Clear the cache and try again
session.getClient().clearCache?()
writeFiles(models, commitText)
.fail((err) => promise.reject(err))
.done (val) => promise.resolve(val)
else
promise.reject(err)

return promise

Expand Down

0 comments on commit 8acc315

Please sign in to comment.