From 3248f7ba49770c3223904703bf16493aff84accf Mon Sep 17 00:00:00 2001 From: Dwynr Date: Fri, 7 Jun 2024 12:34:42 +0200 Subject: [PATCH] fix: list item size, bump sdk, ios fpe --- android/app/build.gradle | 4 +- .../FileProviderEnumerator.swift | 146 +++-------- ios/FileProviderExt/FileProviderUtils.swift | 32 ++- ios/Filen.xcodeproj/project.pbxproj | 8 +- .../xcschemes/FileProviderExt.xcscheme | 5 + nodejs-assets/nodejs-project/main.js | 24 +- .../nodejs-project/package-lock.json | 235 +++++++++++++++++- nodejs-assets/nodejs-project/package.json | 2 +- package-lock.json | 4 +- package.json | 2 +- src/components/Item/Item.tsx | 30 ++- src/lib/node/node.ts | 1 + src/lib/services/setup/setup.ts | 15 +- 13 files changed, 362 insertions(+), 146 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3f19d606..e88b48a8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -119,8 +119,8 @@ android { applicationId "io.filen.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 2072 - versionName "2.0.72" + versionCode 2073 + versionName "2.0.73" } splits { diff --git a/ios/FileProviderExt/FileProviderEnumerator.swift b/ios/FileProviderExt/FileProviderEnumerator.swift index bcadd4a7..d1b7f963 100644 --- a/ios/FileProviderExt/FileProviderEnumerator.swift +++ b/ios/FileProviderExt/FileProviderEnumerator.swift @@ -10,13 +10,6 @@ import Alamofire class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { private let identifier: NSFileProviderItemIdentifier - private let uploadsRangeData = "\"data\":{\"uploads\":[".data(using: .utf8)! - private let foldersRangeData = "],\"folders\":[".data(using: .utf8)! - private let closingRangeData = "}".data(using: .utf8)! - private let openingRangeData = "{".data(using: .utf8)! - private let commaData = ",".data(using: .utf8)! - private let endData = "]}}".data(using: .utf8)! - private let statusFalseData = "\"status\":false".data(using: .utf8)! init (identifier: NSFileProviderItemIdentifier) { self.identifier = identifier @@ -223,18 +216,12 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { func enumerateItems(for observer: NSFileProviderEnumerationObserver, startingAt page: NSFileProviderPage) { Task { do { - guard let rootFolderUUID = FileProviderUtils.shared.rootFolderUUID(), let masterKeys = FileProviderUtils.shared.masterKeys(), let apiKey = MMKVInstance.shared.instance?.string(forKey: "apiKey", defaultValue: nil), let url = URL(string: "https://gateway.filen.io/v3/dir/content") else { + guard let rootFolderUUID = FileProviderUtils.shared.rootFolderUUID(), let masterKeys = FileProviderUtils.shared.masterKeys() else { observer.finishEnumeratingWithError(NSFileProviderError(.notAuthenticated)) return } - let headers: HTTPHeaders = [ - "Authorization": "Bearer \(apiKey)", - "Accept": "application/json", - "Content-Type": "application/json" - ] - if FileProviderUtils.shared.needsFaceID() { observer.finishEnumeratingWithError(NSFileProviderError(.notAuthenticated)) @@ -282,109 +269,52 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator { } let folderUUID = self.identifier == NSFileProviderItemIdentifier.rootContainer || self.identifier.rawValue == "root" || self.identifier.rawValue == NSFileProviderItemIdentifier.rootContainer.rawValue ? rootFolderUUID : self.identifier.rawValue - let tempJSONFileURL = try await FileProviderUtils.shared.sessionManager.download(url, method: .post, parameters: ["uuid": folderUUID], encoding: JSONEncoding.default, headers: headers){ $0.timeoutInterval = 3600 }.validate().serializingDownloadedFileURL().value + var didEnumerate = false - defer { - do { - if FileManager.default.fileExists(atPath: tempJSONFileURL.path) { - try FileManager.default.removeItem(atPath: tempJSONFileURL.path) - } - } catch { - print("[enumerateItems] error:", error) - } + let content = try await FileProviderUtils.shared.fetchFolderContents(uuid: folderUUID) + + if !content.status { + observer.finishEnumeratingWithError(NSFileProviderError(.serverUnreachable)) + + return } - guard let inputStream = InputStream(url: tempJSONFileURL) else { - throw NSError(domain: "enumerateItems", code: 1, userInfo: nil) + if content.data == nil { + observer.finishEnumeratingWithError(NSFileProviderError(.serverUnreachable)) + + return } - inputStream.open() + var existingNames: [String: Bool] = [:] - defer { - inputStream.close() + for folder in content.data!.folders { + let processed = try self.processFolder(folder: folder, masterKeys: masterKeys) + + if (processed.item.name.count > 0) { + let lowercaseName = processed.item.name.lowercased() + + if (existingNames[lowercaseName] == nil) { + existingNames[lowercaseName] = true + + observer.didEnumerate([processed]) + + didEnumerate = true + } + } } - let bufferSize = 1024 - var buffer = [UInt8](repeating: 0, count: bufferSize) - var accumulatedData = Data() - var currentState: FetchFolderContentJSONParseState = .lookingForData - var didParseFiles = false - var didEnumerate = false - - while inputStream.hasBytesAvailable || accumulatedData.count > 0 { - autoreleasepool { - let bytesRead = inputStream.read(&buffer, maxLength: bufferSize) + for file in content.data!.uploads { + let processed = try self.processFile(file: file, masterKeys: masterKeys) + + if (processed.item.name.count > 0) { + let lowercaseName = processed.item.name.lowercased() - if bytesRead > 0 || accumulatedData.count > 0 { - if bytesRead > 0 { - accumulatedData.append(contentsOf: buffer[0.. 0) { - observer.didEnumerate([processed]) - - didEnumerate = true - } - } else { - if let folder = try? FileProviderUtils.shared.jsonDecoder.decode(FetchFolderContentsFolder.self, from: data) { - didParseFiles = true - - let processed = try self.processFolder(folder: folder, masterKeys: masterKeys) - - if (processed.item.name.count > 0) { - observer.didEnumerate([processed]) - - didEnumerate = true - } - } - } - } catch { - print("[enumerateItems] error:", error) - } - - accumulatedData.removeSubrange(0.. Void { Task { do { + guard FunctionRateLimiter.shared.shouldAllowExecution(for: identifier) else { + return + } + guard let rootFolderUUID = self.rootFolderUUID() else { throw NSFileProviderError(.notAuthenticated) } @@ -1403,6 +1407,32 @@ class FileProviderUtils { } } +class FunctionRateLimiter { + private var lastExecutionTimes: [NSFileProviderItemIdentifier: Date] = [:] + private let queue = DispatchQueue(label: "io.filen.app.functionRatelimiter") + + public static let shared: FunctionRateLimiter = { + let instance = FunctionRateLimiter() + + return instance + }() + + func shouldAllowExecution(for identifier: NSFileProviderItemIdentifier) -> Bool { + let now = Date() + let oneSecond: TimeInterval = 1.0 + + return queue.sync { + if let lastExecutionTime = lastExecutionTimes[identifier], now.timeIntervalSince(lastExecutionTime) < oneSecond { + return false + } else { + lastExecutionTimes[identifier] = now + + return true + } + } + } +} + struct BodyStringEncoding: ParameterEncoding { private let body: String diff --git a/ios/Filen.xcodeproj/project.pbxproj b/ios/Filen.xcodeproj/project.pbxproj index 2565b16f..bec8e70b 100644 --- a/ios/Filen.xcodeproj/project.pbxproj +++ b/ios/Filen.xcodeproj/project.pbxproj @@ -932,7 +932,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements; - CURRENT_PROJECT_VERSION = 2072; + CURRENT_PROJECT_VERSION = 2073; DEVELOPMENT_TEAM = 7YTW5D2K7P; ENABLE_BITCODE = NO; INFOPLIST_FILE = Filen/Info.plist; @@ -941,7 +941,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.72; + MARKETING_VERSION = 2.0.73; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -969,7 +969,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements; - CURRENT_PROJECT_VERSION = 2072; + CURRENT_PROJECT_VERSION = 2073; DEVELOPMENT_TEAM = 7YTW5D2K7P; INFOPLIST_FILE = Filen/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -977,7 +977,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.72; + MARKETING_VERSION = 2.0.73; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/ios/Filen.xcodeproj/xcshareddata/xcschemes/FileProviderExt.xcscheme b/ios/Filen.xcodeproj/xcshareddata/xcschemes/FileProviderExt.xcscheme index 199afc64..c9194ae1 100644 --- a/ios/Filen.xcodeproj/xcshareddata/xcschemes/FileProviderExt.xcscheme +++ b/ios/Filen.xcodeproj/xcshareddata/xcschemes/FileProviderExt.xcscheme @@ -58,6 +58,11 @@ launchAutomaticallySubstyle = "2" queueDebuggingEnabled = "No" memoryGraphOnResourceException = "Yes"> + + { try { @@ -2110,10 +2110,10 @@ const loadItems = async ({ url, offlinePath, thumbnailPath, uuid, receiverId, so resolve() }) - .catch(err => { + .catch(() => { loadItemsSemaphore.release() - reject(err) + resolve() }) }) .catch(reject) @@ -2219,10 +2219,10 @@ const loadItems = async ({ url, offlinePath, thumbnailPath, uuid, receiverId, so resolve() }) - .catch(err => { + .catch(() => { loadItemsSemaphore.release() - reject(err) + resolve() }) } }) @@ -2329,10 +2329,10 @@ const loadItems = async ({ url, offlinePath, thumbnailPath, uuid, receiverId, so resolve() }) - .catch(err => { + .catch(() => { loadItemsSemaphore.release() - reject(err) + resolve() }) } }) @@ -2411,10 +2411,10 @@ const loadItems = async ({ url, offlinePath, thumbnailPath, uuid, receiverId, so resolve() }) - .catch(err => { + .catch(() => { loadItemsSemaphore.release() - reject(err) + resolve() }) }) .catch(reject) @@ -2520,10 +2520,10 @@ const loadItems = async ({ url, offlinePath, thumbnailPath, uuid, receiverId, so resolve() }) - .catch(err => { + .catch(() => { loadItemsSemaphore.release() - reject(err) + resolve() }) } }) diff --git a/nodejs-assets/nodejs-project/package-lock.json b/nodejs-assets/nodejs-project/package-lock.json index 69beb085..2745bc89 100644 --- a/nodejs-assets/nodejs-project/package-lock.json +++ b/nodejs-assets/nodejs-project/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@filen/sdk": "^0.1.12", + "@filen/sdk": "^0.1.115", "await-semaphore": "^0.1.3", "axios": "^0.26.0", "crypto-api-v1": "^1.0.0", @@ -25,10 +25,11 @@ } }, "node_modules/@filen/sdk": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/@filen/sdk/-/sdk-0.1.12.tgz", - "integrity": "sha512-Iq0SJCaQZudRx0me900aEsAZbtrOnCWx9PvpVpkNkQv+nrkr/cMN6klzngDuFzjtNhqKVMU+Ngg02aShgWqSgw==", + "version": "0.1.115", + "resolved": "https://registry.npmjs.org/@filen/sdk/-/sdk-0.1.115.tgz", + "integrity": "sha512-Ij+tfwFgvNQ/9FTMoJ8104wopMF3N+0wjd19WbAo296CbJ9a+fvJdY8155URJewBAFHbNvV+LsJI3pyRxvaVpA==", "dependencies": { + "agentkeepalive": "^4.5.0", "axios": "^1.6.7", "crypto-api-v1": "^1.0.0", "crypto-js": "^4.2.0", @@ -36,10 +37,12 @@ "js-crypto-key-utils": "^1.0.7", "mime-types": "^2.1.35", "progress-stream": "^2.0.0", + "socket.io-client": "^2.5.0", + "striptags": "^3.2.0", "uuid": "^9.0.1" }, "engines": { - "node": "^18" + "node": ">=18" } }, "node_modules/@filen/sdk/node_modules/axios": { @@ -97,6 +100,27 @@ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" }, + "node_modules/after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha512-QbJ0NTQ/I9DI3uSJA4cbexiwQeRAfjPScqIbSjUDd9TOrcg6pTkdgziesOqxBMBzit8vFCTwrP27t13vFOORRA==" + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/arraybuffer.slice": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", + "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==" + }, "node_modules/asn1.js": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", @@ -126,6 +150,19 @@ "follow-redirects": "^1.14.8" } }, + "node_modules/backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha512-zj6Z6M7Eq+PBZ7PQxl5NT665MvJdAkzp0f60nAJ+sLaSCBPMwVak5ZegFbgVCzFcCJTKFoMizvM5Ld7+JrRJHA==" + }, + "node_modules/base64-arraybuffer": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz", + "integrity": "sha512-a1eIFi4R9ySrbiMuyTGx5e92uRH5tQY6kArNcFaKBUleIoLjdjBg7Zxm3Mqm3Kmkf27HLR/1fnxX9q8GQ7Iavg==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -145,6 +182,11 @@ } ] }, + "node_modules/blob": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==" + }, "node_modules/bn.js": { "version": "4.12.0", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", @@ -174,6 +216,24 @@ "node": ">= 0.8" } }, + "node_modules/component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha512-WZveuKPeKAG9qY+FkYDeADzdHyTYdIboXS59ixDeRJL5ZhxpqUnxSOwop4FQjMsiYm3/Or8cegVbpAHNA7pHxw==" + }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha512-w+LhYREhatpVqTESyGFg3NlP6Iu0kEKUHETY9GoZP/pQyW4mHFZuFWRUCIqVPZ36ueVLtoOEZaAqbCF2RDndaA==" + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -197,6 +257,19 @@ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" }, + "node_modules/debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -228,6 +301,36 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "node_modules/engine.io-client": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.5.3.tgz", + "integrity": "sha512-qsgyc/CEhJ6cgMUwxRRtOndGVhIu5hpL5tR4umSpmX/MvkFoIxUTM7oFMDQumHNzlNLwSVy6qhstFPoWTf7dOw==", + "dependencies": { + "component-emitter": "~1.3.0", + "component-inherit": "0.0.3", + "debug": "~3.1.0", + "engine.io-parser": "~2.2.0", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.6", + "parseuri": "0.0.6", + "ws": "~7.4.2", + "xmlhttprequest-ssl": "~1.6.2", + "yeast": "0.1.2" + } + }, + "node_modules/engine.io-parser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.1.tgz", + "integrity": "sha512-x+dN/fBH8Ro8TFwJ+rkB2AmuVw9Yu2mockR/p3W8f8YtExwFgDvBDi0GWyb4ZLkpahtDGZgtr3zLovanJghPqg==", + "dependencies": { + "after": "0.8.2", + "arraybuffer.slice": "~0.0.7", + "base64-arraybuffer": "0.1.4", + "blob": "0.0.5", + "has-binary2": "~1.0.2" + } + }, "node_modules/follow-redirects": { "version": "1.15.5", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", @@ -278,6 +381,24 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, + "node_modules/has-binary2": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", + "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "dependencies": { + "isarray": "2.0.1" + } + }, + "node_modules/has-binary2/node_modules/isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha512-c2cu3UxbI+b6kR3fy0nRnAhodsvR9dx7U5+znCOzdj6IfP3upFURTr0Xl5BlQZNKZjEtxrmVyfSdeE3O57smoQ==" + }, + "node_modules/has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha512-g5VNKdkFuUuVCP9gYfDJHjK2nqdQJ7aDLTnycnc2+RvsOQbuLdF5pm7vuE5J76SEBIQjs4kQY/BWq74JUmjbXA==" + }, "node_modules/hash.js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", @@ -321,6 +442,14 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -340,6 +469,11 @@ } ] }, + "node_modules/indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==" + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -543,6 +677,21 @@ "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/parseqs": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz", + "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==" + }, + "node_modules/parseuri": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz", + "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==" + }, "node_modules/pngjs": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", @@ -606,11 +755,49 @@ "ieee754": "^1.2.1" } }, + "node_modules/socket.io-client": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.5.0.tgz", + "integrity": "sha512-lOO9clmdgssDykiOmVQQitwBAF3I6mYcQAo7hQ7AM6Ny5X7fp8hIJ3HcQs3Rjz4SoggoxA1OgrQyY8EgTbcPYw==", + "dependencies": { + "backo2": "1.0.2", + "component-bind": "1.0.0", + "component-emitter": "~1.3.0", + "debug": "~3.1.0", + "engine.io-client": "~3.5.0", + "has-binary2": "~1.0.2", + "indexof": "0.0.1", + "parseqs": "0.0.6", + "parseuri": "0.0.6", + "socket.io-parser": "~3.3.0", + "to-array": "0.1.4" + } + }, + "node_modules/socket.io-parser": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.3.tgz", + "integrity": "sha512-qOg87q1PMWWTeO01768Yh9ogn7chB9zkKtQnya41Y355S0UmpXgpcrFwAgjYJxu9BdKug5r5e9YtVSeWhKBUZg==", + "dependencies": { + "component-emitter": "~1.3.0", + "debug": "~3.1.0", + "isarray": "2.0.1" + } + }, + "node_modules/socket.io-parser/node_modules/isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha512-c2cu3UxbI+b6kR3fy0nRnAhodsvR9dx7U5+znCOzdj6IfP3upFURTr0Xl5BlQZNKZjEtxrmVyfSdeE3O57smoQ==" + }, "node_modules/speedometer": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/speedometer/-/speedometer-1.0.0.tgz", "integrity": "sha512-lgxErLl/7A5+vgIIXsh9MbeukOaCb2axgQ+bKCdIE+ibNT4XNYGNCR1qFEGq6F+YDASXK3Fh/c5FgtZchFolxw==" }, + "node_modules/striptags": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz", + "integrity": "sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw==" + }, "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", @@ -647,6 +834,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha512-LhVdShQD/4Mk4zXNroIQZJC+Ap3zgLcDuwEdcmLv9CCO73NWockQDwyUnW/m8VX/EElfL6FcYx7EeutN4HJA6A==" + }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", @@ -677,6 +869,34 @@ "uuid": "8.3.2" } }, + "node_modules/ws": { + "version": "7.4.6", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xmlhttprequest-ssl": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.6.3.tgz", + "integrity": "sha512-3XfeQE/wNkvrIktn2Kf0869fC0BN6UpydVasGIeSm2B1Llihf7/0UfZM+eCkOw3P7bP4+qPgqhm7ZoxuJtFU0Q==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -684,6 +904,11 @@ "engines": { "node": ">=0.4" } + }, + "node_modules/yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha512-8HFIh676uyGYP6wP13R/j6OJ/1HwJ46snpvzE7aHAN3Ryqh2yX6Xox2B4CUmTwwOIzlG3Bs7ocsP5dZH/R1Qbg==" } } } diff --git a/nodejs-assets/nodejs-project/package.json b/nodejs-assets/nodejs-project/package.json index 510e185d..10579230 100644 --- a/nodejs-assets/nodejs-project/package.json +++ b/nodejs-assets/nodejs-project/package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "@filen/sdk": "^0.1.12", + "@filen/sdk": "^0.1.115", "await-semaphore": "^0.1.3", "axios": "^0.26.0", "crypto-api-v1": "^1.0.0", diff --git a/package-lock.json b/package-lock.json index 289b97cd..09f5245b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filen-mobile", - "version": "2.0.72", + "version": "2.0.73", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "filen-mobile", - "version": "2.0.72", + "version": "2.0.73", "hasInstallScript": true, "dependencies": { "@notifee/react-native": "^7.8.0", diff --git a/package.json b/package.json index 592d9c23..5944e6eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filen-mobile", - "version": "2.0.72", + "version": "2.0.73", "private": true, "scripts": { "android": "react-native run-android", diff --git a/src/components/Item/Item.tsx b/src/components/Item/Item.tsx index b13036aa..d437f500 100644 --- a/src/components/Item/Item.tsx +++ b/src/components/Item/Item.tsx @@ -1,4 +1,4 @@ -import React, { memo, useEffect, useMemo, useRef, useState } from "react" +import React, { memo, useEffect, useMemo, useRef, useState, useCallback } from "react" import { Text, View, @@ -48,8 +48,9 @@ export interface ListItemProps extends ItemBaseProps { export const ListItem = memo(({ item, index, darkMode, hideFileNames, hideSizes, hideThumbnails, lang, route }: ListItemProps) => { const fetched = useRef(false) const [size, setSize] = useState(item.size) + const currentItemUUID = useRef(item.uuid) - useEffect(() => { + const folderSize = useCallback(() => { if (item.type == "folder" && !fetched.current) { fetched.current = true @@ -72,6 +73,17 @@ export const ListItem = memo(({ item, index, darkMode, hideFileNames, hideSizes, } }, [item.uuid, item.name, index, route]) + if (currentItemUUID.current !== item.uuid) { + fetched.current = false + currentItemUUID.current = item.uuid + + setSize(item.size) + } + + useEffect(() => { + folderSize() + }, [folderSize]) + return ( (false) const [size, setSize] = useState(item.size) + const currentItemUUID = useRef(item.uuid) const windowWidth: number = useMemo(() => { return dimensions.width - (insets.left + insets.right) - 40 }, [dimensions, insets]) - useEffect(() => { + const folderSize = useCallback(() => { if (item.type == "folder" && !fetched.current) { fetched.current = true @@ -290,6 +303,17 @@ export const GridItem = memo( } }, [item.uuid, item.name, index, route]) + if (currentItemUUID.current !== item.uuid) { + fetched.current = false + currentItemUUID.current = item.uuid + + setSize(item.size) + } + + useEffect(() => { + folderSize() + }, [folderSize]) + return ( Promise loadItems: (params: { url: string diff --git a/src/lib/services/setup/setup.ts b/src/lib/services/setup/setup.ts index ee58f9a2..207c76de 100644 --- a/src/lib/services/setup/setup.ts +++ b/src/lib/services/setup/setup.ts @@ -225,18 +225,19 @@ export async function setupSDK({ userId, baseFolderUUID }: { userId: number; bas await fs.mkdir(sdkTmpPath, true) await global.nodeThread.initSDK({ - email: storage.getString("email") ?? "", - password: "", + email: storage.getString("email") ?? "anonymous", + password: "anonymous", twoFactorCode: "XXXXXX", - masterKeys: getMasterKeys(), - apiKey: storage.getString("apiKey") ?? "", - publicKey: storage.getString("publicKey") ?? "", - privateKey: storage.getString("privateKey") ?? "", + masterKeys: getMasterKeys() ?? ["anonymous"], + apiKey: storage.getString("apiKey") ?? "anonymous", + publicKey: storage.getString("publicKey") ?? "anonymous", + privateKey: storage.getString("privateKey") ?? "anonymous", authVersion: (storage.getNumber("authVersion") as 1 | 2) ?? 2, baseFolderUUID, userId, metadataCache: true, - tmpPath: sdkTmpPathPosix.startsWith("/") ? sdkTmpPathPosix : "/" + sdkTmpPathPosix + tmpPath: sdkTmpPathPosix.startsWith("/") ? sdkTmpPathPosix : "/" + sdkTmpPathPosix, + connectToSocket: false }) storage.set("sdkInit", true)