MCPcopy Create free account
hub / github.com/facebook/Rapid / save

Method save

modules/core/UploaderSystem.js:117–160  ·  view source on GitHub ↗

* save

(tryAgain, checkConflicts)

Source from the content-addressed store, hash-verified

115 * save
116 */
117 save(tryAgain, checkConflicts) {
118 // Guard against accidentally entering save code twice - iD#4641
119 if (this._isSaving && !tryAgain) return;
120
121 const context = this.context;
122 const osm = context.services.osm;
123 if (!osm) return;
124
125 // If user somehow got logged out mid-save, try to reauthenticate..
126 // This can happen if they were logged in from before, but the tokens are no longer valid.
127 if (!osm.authenticated()) {
128 osm.authenticate(err => {
129 if (!err) {
130 this.save(tryAgain, checkConflicts); // continue where we left off..
131 }
132 });
133 return;
134 }
135
136 if (!this._isSaving) {
137 this._isSaving = true;
138 this.emit('saveStarted');
139 }
140
141 // reset variables
142 this._localGraph = null;
143 this._remoteGraph = null;
144 this._toCheckIDs = new Set();
145 this._toLoadIDs = new Set();
146 this._loadedIDs = new Set();
147 this._conflicts = [];
148 this._errors = [];
149
150 // Store original changes, in case user wants to download them as an .osc file
151 const editor = context.systems.editor;
152 this._origChanges = editor.changes(actionDiscardTags(editor.difference(), this._discardTags));
153
154 // Attempt a fast upload first.. If there are conflicts, re-enter with `checkConflicts = true`
155 if (!checkConflicts) {
156 this._tryUpload();
157 } else {
158 this._startConflictCheck();
159 }
160 }
161
162
163 /**

Callers 5

_uploadCallbackMethod · 0.95
renderFunction · 0.80
saveWithRetryFunction · 0.80
saveWithRetryFunction · 0.80

Calls 7

_tryUploadMethod · 0.95
_startConflictCheckMethod · 0.95
actionDiscardTagsFunction · 0.90
authenticatedMethod · 0.80
authenticateMethod · 0.80
differenceMethod · 0.80
changesMethod · 0.45

Tested by

no test coverage detected