diff --git a/package-lock.json b/package-lock.json index 680314cc26..3206470e8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,12 +71,12 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "^0.9.0", + "tc-source-content-updater": "0.9.1", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", "truncate-utf8-bytes": "1.0.2", - "tsv-groupdata-parser": "0.10.1", + "tsv-groupdata-parser": "0.10.2", "usfm-js": "3.3.1", "uuid": "3.2.1", "word-aligner": "1.0.0", @@ -22903,9 +22903,9 @@ } }, "node_modules/tc-source-content-updater": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.0.tgz", - "integrity": "sha512-9SrIlTnf8WiO8QbOGGrRs+ix8iOLgW0VN1W2k/XjO3KEQe5uC3UVwpncvCOzrI6WwLYCZ6oOfU4YdwrlWkZTKQ==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1.tgz", + "integrity": "sha512-rUc6ueKKE/LicCnhGwvJgKn1vyonNMFm/VsiVj32zq5XVgex1o8i8Tl88Z090IceSxE9dvworLiFKkEHqenilQ==", "dependencies": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", @@ -23704,9 +23704,9 @@ } }, "node_modules/tsv-groupdata-parser": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.1.tgz", - "integrity": "sha512-f5OVdAqon4vsI4Ja4pyT4j8kTNBiezvByOtApwfTax4GUFZQHvEVdoETHbW1qvuHzXAeGoohIdkO4sR+qchKOg==", + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.2.tgz", + "integrity": "sha512-rLcplT7O/ZhGPMl50YXoSguaEAPVYbjz4s3MlpjcBPM5v/IWKpuOU06GOxIeYJGveUdhhNfqKs2AqZ7+72yLvg==", "dependencies": { "fs-extra": "^7.0.1", "ospath": "^1.2.2", @@ -45074,9 +45074,9 @@ } }, "tc-source-content-updater": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.0.tgz", - "integrity": "sha512-9SrIlTnf8WiO8QbOGGrRs+ix8iOLgW0VN1W2k/XjO3KEQe5uC3UVwpncvCOzrI6WwLYCZ6oOfU4YdwrlWkZTKQ==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1.tgz", + "integrity": "sha512-rUc6ueKKE/LicCnhGwvJgKn1vyonNMFm/VsiVj32zq5XVgex1o8i8Tl88Z090IceSxE9dvworLiFKkEHqenilQ==", "requires": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", @@ -45686,9 +45686,9 @@ } }, "tsv-groupdata-parser": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.1.tgz", - "integrity": "sha512-f5OVdAqon4vsI4Ja4pyT4j8kTNBiezvByOtApwfTax4GUFZQHvEVdoETHbW1qvuHzXAeGoohIdkO4sR+qchKOg==", + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.2.tgz", + "integrity": "sha512-rLcplT7O/ZhGPMl50YXoSguaEAPVYbjz4s3MlpjcBPM5v/IWKpuOU06GOxIeYJGveUdhhNfqKs2AqZ7+72yLvg==", "requires": { "fs-extra": "^7.0.1", "ospath": "^1.2.2", diff --git a/package.json b/package.json index e2ebc2b942..6926b1a6e2 100644 --- a/package.json +++ b/package.json @@ -176,12 +176,12 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "^0.9.0", + "tc-source-content-updater": "0.9.1", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", "truncate-utf8-bytes": "1.0.2", - "tsv-groupdata-parser": "0.10.1", + "tsv-groupdata-parser": "0.10.2", "usfm-js": "3.3.1", "uuid": "3.2.1", "word-aligner": "1.0.0", diff --git a/src/js/actions/__tests__/MigrationActions.test.js b/src/js/actions/__tests__/MigrationActions.test.js index 9c471aa555..d61550ae9f 100644 --- a/src/js/actions/__tests__/MigrationActions.test.js +++ b/src/js/actions/__tests__/MigrationActions.test.js @@ -326,10 +326,10 @@ describe('migrate tCore resources', () => { expect(fs.existsSync(path.join(USER_RESOURCES_PATH, 'grc'))).toBeFalsy(); // should remove folder }); - it('test with older version of ugnt in grc/bible - should be removed', () => { + it('test with older version of ugnt in grc/bible - should not be removed', () => { // given const expectedHelpsVers = false; - const expectedBibleVers = ['v0.2']; + const expectedBibleVers = ['v0.1', 'v0.2']; const bibleId = 'ugnt'; fs.copySync(path.join(STATIC_RESOURCES_PATH, 'el-x-koine/bibles', bibleId, 'v0.2'), path.join(USER_RESOURCES_PATH, 'grc/bibles', bibleId, 'v0.1')); const migrateResourcesFolder = MigrationActions.migrateResourcesFolder(); diff --git a/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap b/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap index fe0a8b57ba..55553e4dc9 100644 --- a/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap +++ b/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap @@ -19,8 +19,9 @@ Array [ ] `; -exports[`migrate tCore resources Test grc resource migration test with older version of ugnt in grc/bible - should be removed 1`] = ` +exports[`migrate tCore resources Test grc resource migration test with older version of ugnt in grc/bible - should not be removed 1`] = ` Array [ + "/Users/jest/mock/path/translationCore/resources/el-x-koine/bibles/ugnt/v0.1", "/Users/jest/mock/path/translationCore/resources/el-x-koine/bibles/ugnt/v0.2", "/Users/jest/mock/path/translationCore/resources/el-x-koine/translationHelps/translationWords/v8", "/Users/jest/mock/path/translationCore/resources/en/bibles/ult/v12.1", diff --git a/src/js/helpers/ResourcesHelpers.js b/src/js/helpers/ResourcesHelpers.js index f3c67725d5..ad23f22a3e 100644 --- a/src/js/helpers/ResourcesHelpers.js +++ b/src/js/helpers/ResourcesHelpers.js @@ -1208,16 +1208,17 @@ export function moveResourcesFromOldGrcFolder() { /** * find out which Original Language Bible versions are needed by installed tNs. Only keep the needed versions. * The other versions are deleted. - * @param languageId - * @param resourceId - * @param resourcePath + * @param {string} languageId + * @param {string} resourceId + * @param {string} resourcePath - path for versions of current resource + * @param {string} resourcesPath - base path for all resources * @return {boolean} - returns true if all old resources can be deleted */ -export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath) { +export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath, resourcesPath) { let deleteOldResources = true; // by default we do not keep old versions of resources if (BibleHelpers.isOriginalLanguageBible(languageId, resourceId)) { - const requiredVersions = getOtherTnsOLVersions(USER_RESOURCES_PATH, resourceId).sort((a, b) => + const requiredVersions = getOtherTnsOLVersions(resourcesPath, resourceId).sort((a, b) => -ResourceAPI.compareVersions(a, b), // do inverted sort ); console.log('preserveNeededOrigLangVersions: requiredVersions', requiredVersions); @@ -1272,15 +1273,13 @@ export function getMissingResources() { } else if (!fs.existsSync(userResourcePath)) {// if resource isn't found in user resources folder. copyAndExtractResource(staticResourcePath, userResourcePath, languageId, resourceId, resourceType); } else { // compare resources manifest modified time + const userResourceVersionPath = ResourceAPI.getLatestVersion(userResourcePath); const staticResourceVersionPath = ResourceAPI.getLatestVersion(staticResourcePath); - const version = path.basename(staticResourceVersionPath); - const userResourceVersionPath = path.join(userResourcePath, version); - const userResourceExists = fs.existsSync(userResourceVersionPath); let isOldResource = false; const filename = 'manifest.json'; const staticResourceManifestPath = path.join(staticResourceVersionPath, filename); - if (userResourceExists) { + if (userResourceVersionPath) { const userResourceManifestPath = path.join(userResourceVersionPath, filename); if (fs.existsSync(userResourceManifestPath) && fs.existsSync(staticResourceManifestPath)) { @@ -1312,7 +1311,7 @@ export function getMissingResources() { isOldResource = true; } - const deleteOldResources = preserveNeededOrigLangVersions(languageId, resourceId, userResourcePath); + const deleteOldResources = preserveNeededOrigLangVersions(languageId, resourceId, userResourcePath, USER_RESOURCES_PATH); if (isOldResource) { console.log(`getMissingResources() - checking ${languageId} ${resourceId} - old resource found`);