From a5ab7a6940be10be6fc81696b3293e2e2f1580fd Mon Sep 17 00:00:00 2001 From: Umberto Pepato Date: Mon, 17 Jun 2024 21:54:19 +0200 Subject: [PATCH] fix(teaching): update file name failing when already scheduled (#496) --- ios/Podfile.lock | 2 +- package-lock.json | 7 ++++--- package.json | 2 +- src/core/hooks/useDownloadCourseFile.ts | 12 ++++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6777661e..9b3918db 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1020,7 +1020,7 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/yoga" SPEC CHECKSUMS: - boost: 7dcd2de282d72e344012f7d6564d024930a6a440 + boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: d5c36294933aa344046699700b9ae9c2e10db18e diff --git a/package-lock.json b/package-lock.json index da86b3c7..e023f3a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,7 +125,7 @@ "jest": "^29.2.1", "lint-staged": "^13.0.3", "metro-react-native-babel-preset": "0.76.9", - "pod-install": "0.1.38", + "pod-install": "^0.2.2", "prettier": "^2.7.1", "react-test-renderer": "18.2.0", "standard-version": "^9.5.0", @@ -15837,9 +15837,10 @@ } }, "node_modules/pod-install": { - "version": "0.1.38", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/pod-install/-/pod-install-0.2.2.tgz", + "integrity": "sha512-NgQpKiuWZo8mWU+SVxmrn+ARy9+fFYzW53ze6CDTo70u5Ie8AVSn7FqolDC/c7+N4/kQ1BldAnXEab6SNYA8xw==", "dev": true, - "license": "MIT", "bin": { "pod-install": "build/index.js" } diff --git a/package.json b/package.json index 90ee74a5..22d58533 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "jest": "^29.2.1", "lint-staged": "^13.0.3", "metro-react-native-babel-preset": "0.76.9", - "pod-install": "0.1.38", + "pod-install": "^0.2.2", "prettier": "^2.7.1", "react-test-renderer": "18.2.0", "standard-version": "^9.5.0", diff --git a/src/core/hooks/useDownloadCourseFile.ts b/src/core/hooks/useDownloadCourseFile.ts index 73319455..be4fda6f 100644 --- a/src/core/hooks/useDownloadCourseFile.ts +++ b/src/core/hooks/useDownloadCourseFile.ts @@ -68,10 +68,14 @@ export const useDownloadCourseFile = ( updateDownload({ isDownloaded: true }); } else { // Update the name when changed - await mkdir(dirname(toFile)); - await moveFile(cachedFilePath, toFile); - await cleanupEmptyFolders(coursesFilesCachePath); - refresh(); + try { + await mkdir(dirname(toFile)); + await moveFile(cachedFilePath, toFile); + await cleanupEmptyFolders(coursesFilesCachePath); + refresh(); + } catch (_) { + // File rename was already scheduled + } } } else { updateDownload({ isDownloaded: false });