|
21 | 21 |
|
22 | 22 | /*global path, logger, jsPromise*/ |
23 | 23 |
|
| 24 | +/** |
| 25 | + * This file outlines the process phcode follows to restore files if the application crashes or if a user closes |
| 26 | + * the application without saving their files. |
| 27 | + * |
| 28 | + * For each project in phcode, there's a unique 'restore' folder located in the appdata directory. |
| 29 | + * This folder is named according to the pattern <projectName>-<projectPathHash>. |
| 30 | + * |
| 31 | + * The restore folder monitors all files being edited in phcode, and this tracking is updated every 5 seconds |
| 32 | + * by a function called changeScanner. The function backs up changes every 5 seconds, and only unsaved files |
| 33 | + * that have been modified since the last backup are synced again. When files are saved, they're removed from |
| 34 | + * the backup during this changeScanner process because there's no need to restore them. |
| 35 | + * |
| 36 | + * When opening a project, we first check for the existence of a 'restore' folder associated with that project |
| 37 | + * and scan for any files within it. If we find any, these files are marked for potential restoration. |
| 38 | + * |
| 39 | + * During this process, we load all recoverable file data into memory and temporarily halt any writing activity |
| 40 | + * to the 'restore' folder. This safeguard is in place to prevent any accidental overwriting of the restore files' |
| 41 | + * data in case the user edits any files currently marked for restoration. |
| 42 | + * |
| 43 | + * Once we've cached the data from the restore files, we present a notification to the user, asking if they would |
| 44 | + * like these files to be restored. If the user agrees, we then open all of these files in the editor and populate |
| 45 | + * them with the previously cached, restored content. |
| 46 | + */ |
| 47 | + |
24 | 48 | define(function (require, exports, module) { |
25 | 49 | const NativeApp = brackets.getModule("utils/NativeApp"), |
26 | 50 | FileSystem = brackets.getModule("filesystem/FileSystem"), |
|
0 commit comments