Tangerine-Community / Tangerine

Digitize your offline data collection. Create your Forms online with Tangerine Editor, conduct them offline with the Tangerine Android App. All results you collect can be exported as a CSV file, easy for processing in a spreadsheet. Tangerine has been used in over 1 million assessments and surveys in over 60 countries and in 100 languages.
http://www.tangerinecentral.org/
GNU General Public License v3.0
49 stars 29 forks source link

Make Maintenance -> Cleanup Files more robust #3097

Open chrisekelley opened 2 years ago

chrisekelley commented 2 years ago

Current version: v3.20.1 Upgraded from: Issue on tablet

Expected behavior

"Pruning files" error message dismissed upon completion

Actual behavior and Steps to reproduce the behavior

If tit is a new install and there has not yet been a backup or restore, the relevant dirs are not avail for deletion and an error occurs.

chrisekelley commented 2 years ago

Relevant code:

[10:08 AM] Kelley, Chris
if (confirmCheck) {
const process = this.processMonitorService.start('pruneFiles', Object(src_app_shared_translation_marker__WEBPACK_IMPORTED_MODULE_1__["_TRANSLATE"])('Pruning files...'));
yield this.pruneFilesInPath(window['cordova'].file.externalDataDirectory);
yield this.pruneFilesInPath(window['cordova'].file.externalRootDirectory + 'Download/restore/');
yield this.pruneFilesInPath(window['cordova'].file.externalRootDirectory + 'Documents/Tangerine/backups/');
yield this.pruneFilesInPath(window['cordova'].file.externalRootDirectory + 'Documents/Tangerine/restore/');
this.processMonitorService.stop(process.id);
}

Proposed sol'n: Surround each pruneFiles in a try/catch.