diag('doSave('+versionId+') - exit - found a pending save for versionId '+versionId,this.resource,newDate());
diag(`doSave(${versionId}) - exit - found a pending save for versionId ${versionId}`,this.resource,newDate());
returnpendingSave;
}
// Return early if not dirty or version changed meanwhile
//
// Scenario A: user invoked save action even though the model is not dirty
// Scenario B: auto save was triggered for a certain change by the user but meanwhile the user changed
// the contents and the version for which auto save was started is no longer the latest.
// Thus we avoid spawning multiple auto saves and only take the latest.
//
if(!this.dirty||versionId!==this.versionId){
diag('doSave('+versionId+') - exit - because not dirty and/or versionId is different (this.isDirty: '+this.dirty+', this.versionId: '+this.versionId+')',this.resource,newDate());
diag(`doSave(${versionId}) - exit - because not dirty and/or versionId is different (this.isDirty: ${this.dirty}, this.versionId: ${this.versionId})`,this.resource,newDate());
returnTPromise.as<void>(null);
}
// Return if currently saving by scheduling another auto save. Never ever must 2 saves execute at the same time because
// this can lead to dirty writes and race conditions
//
// Scenario: auto save was triggered and is currently busy saving to disk. this takes long enough that another auto save
// kicks in. since we never want to trigger 2 saves at the same time, we push out this auto save for the
// configured auto save delay assuming that it can proceed next time it triggers.
//
if(this.isBusySaving()){
diag('doSave('+versionId+') - exit - because busy saving',this.resource,newDate());
diag(`doSave(${versionId}) - exit - because busy saving`,this.resource,newDate());
// Avoid endless loop here and guard if auto save is disabled