Conversation
|
@Tyriar, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bpasero, @joaomoreno and @egamma to be potential reviewers. |
…68_load_backups_on_main_process
…68_load_backups_on_main_process
It's no longer needed now that the workspace is restored.
|
@Tyriar there are merge conflicts? |
|
I merged. |
| @IEventService private eventService: IEventService, | ||
| @ITextFileService private textFileService: ITextFileService, | ||
| @IBackupService private backupService: IBackupService | ||
| @IBackupFileService private backupFileService: IBackupFileService |
| return path.workspacePath; | ||
| } | ||
| return platform.isLinux ? path.workspacePath : path.workspacePath.toLowerCase(); | ||
| const workspacesWithBackups = this.backupService.getWorkspaceBackupPathsSync(); |
There was a problem hiding this comment.
As reported in a different issue that code should really move out of the open() method and only be used from the first startup code. Otherwise it makes it very hard to understand what this method is actually doing (it is already quite complex).
| ) { | ||
| super(); | ||
| this.resource = resource; | ||
| this.restoreResource = restoreResource; |
There was a problem hiding this comment.
As mentioned before I think we can get rid of the restoreResource also for untitled. The untitled model should go to the backup service and ask for available backups with the resource URI, similar to how text files now ask.
| this.backupPromises.push(promise); | ||
|
|
||
| return promise; | ||
| // TODO: Introduce an event on IUntitledEditorService so this can be moved to BackupModelService? |
| @IFileService private fileService: IFileService, | ||
| @IConfigurationService private configurationService: IConfigurationService | ||
| @IConfigurationService private configurationService: IConfigurationService, | ||
| @IBackupService private backupService: IBackupService, |
| return false; // the backup went smoothly, no veto | ||
| }); | ||
| }); | ||
| if (this.backupService.isHotExitEnabled) { |
There was a problem hiding this comment.
Let the backup service listen to the lifecycle method and do it in there. Here I would only check if hot exit is enabled to see if confirmation is needed.
There was a problem hiding this comment.
I did this first but regardless there needs to be some communication between the 2 services. BackupService needs to essentially be run both before (check if hot exit) and after (cleanup backups) TextFileService.beforeShutdown. Also the shutdown event doesn't work as it has to be synchronous and BackupService,cleanupBackupsBeforeShutdown is async.
There was a problem hiding this comment.
Ok maybe textFileServices should use eventing or similar so that we can further decouple this into the backup service.
| } | ||
|
|
||
| return this.cleanupBackupsBeforeShutdown(); | ||
| return this.backupService.cleanupBackupsBeforeShutdown(); // all good, no veto |
There was a problem hiding this comment.
All of the cleanupBackupsBeforeShutdown should move out into the backup service that itself should listen to lifecycle events.
|
|
||
| this.fileService.discardBackup(this.resource); | ||
| // TODO: Can this be moved to BackupModelService? | ||
| this.backupFileService.discardAndDeregisterResource(this.resource); |
There was a problem hiding this comment.
Yes, I suggest another event on the service maybe when this model gets disposed.
| return true; | ||
| } | ||
|
|
||
| public get onModelContentChanged(): Event<TextFileModelChangeEvent> { |
There was a problem hiding this comment.
I see the need for an event when untitled or text files are changing so that the backup service can do its business, however I fear that this comes at the cost of spam: you will see many model content change events while the user is typing, so basically each key press will trigger this event. Performance should always be something to be concerned of, especially when it is typing performance we are talking about.
Some ideas:
- buffer the model content change event and only start to emit the change after a certain delay
- do not always create an event object to send around
I think buffering would be a good idea anyway because backups should also not be created without some delay.
|
@Tyriar looking a lot better. I like the direction. My only concern besides the comments I added is about the amount of events that are being sent now while typing. See my comment in the review on that topic. |
fcf9dba to
f8ed5aa
Compare
…ot_exit/14068_load_backups_on_main_process
…68_load_backups_on_main_process
|
@Tyriar replied to your comments, let me know when I should review again. |
…68_load_backups_on_main_process
|
@bpasero ready for another review! If you consider any of these issues to be must fix before merge please label them with |
| fs.mkdirSync(this.backupHome); | ||
| } | ||
| fs.writeFileSync(this.workspacesJsonPath, JSON.stringify(this.workspacesJsonContent)); | ||
| } catch (ex) { |
There was a problem hiding this comment.
@Tyriar maybe add at least some logging here to be able to find out about issues more easily.
| @@ -0,0 +1,164 @@ | |||
| /*--------------------------------------------------------------------------------------------- | |||
|
@Tyriar only few comments left. my assumption is that you extracted the bigger feedback I gave into issues to look into and that is fine so that we can continue on master in these. |
|
Fix warnings in 97371ad (not sure why I can't reply to that comment). |
|
@bpasero yes we've been tracking all the comments in issues, the important ones have are in the November milestone. |
…68_load_backups_on_main_process
|
Got the go ahead from @bpasero to merge, all tests are passing and did a manual smoke test on Mac and Windows to double check nothing has regressed since our internal test the other day. Merging! 🎆 |
| const workspacesWithBackups = this.backupService.getWorkspaceBackupPaths(); | ||
|
|
||
| workspacesWithBackups.forEach(workspacePath => { | ||
| if (!fs.existsSync(workspacePath)) { |
There was a problem hiding this comment.
@Tyriar would it be possible that we have a backup workspace without backups to restore? maybe we should add more checks here that a backup workspace path should only cause a window to open if it has backups, otherwise it gets deleted. I am thinking of situations where we the backup workspace gets out of sync with the backups within (for whatever reason - e.g. crash). This would prevent bugs where multiple windows just open even though there are no backups.
| delete configuration.filesToCreate; | ||
| delete configuration.filesToDiff; | ||
|
|
||
| // Update untitled files to restore so they come through in the reloaded window |
There was a problem hiding this comment.
@Tyriar I am thinking more and more that untitled editors with backups should not be loaded from the main side but rather from the window itself. Files for example restore because we store their state into local storage (via IEditorInputFactory - see https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/common/editor/editorStacksModel.ts#L621).
If we add a factory for untitled editors, we would just rely on that to bring the untitled back on reopen. It would also fix the issue that untitled would reopen at the right location where they where before.
| return; | ||
| } | ||
|
|
||
| const untitledToRestore = this.backupService.getWorkspaceUntitledFileBackupsSync(Uri.file(workspacePath)).map(filePath => { |
There was a problem hiding this comment.
@Tyriar same comment here about how to restore untitled files. This would not be needed if untitled had input factory.
| } | ||
|
|
||
| // Register new paths for backup | ||
| this.backupService.pushWorkspaceBackupPathsSync(iPathsToOpen.filter(p => p.workspacePath).map(p => Uri.file(p.workspacePath))); |
There was a problem hiding this comment.
@Tyriar should this only happen if hot exit is enabled in settings?
There was a problem hiding this comment.
It should still happen so that it gets recorded and restored if there was a crash.
| }; | ||
| }); | ||
|
|
||
| // Add any untitled files to be restored from backup |
There was a problem hiding this comment.
@Tyriar again this would not be needed if we had untitled editor factory.
Launch VSCodetarget launches multiple window #14060 Correctly clean up workspace backups when exiting (873d095)Backup*Services and leverage events