Skip to content

Commit

Permalink
fix: eng
Browse files Browse the repository at this point in the history
  • Loading branch information
gronxb committed Feb 20, 2025
1 parent fe52546 commit 2d329e3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/react-native/ios/HotUpdater/HotUpdater.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ - (void)updateBundle:(NSString *)bundleId zipUrl:(NSURL *)zipUrl completion:(voi
return;
}

// 앱 전용 경로 설정 (동적으로 NSSearchPathForDirectoriesInDomains 사용)
// Set app-specific path (dynamically using NSSearchPathForDirectoriesInDomains)
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSString *updatedDir = [documentsPath stringByAppendingPathComponent:@"bundle-store"];
NSString *zipFilePath = [updatedDir stringByAppendingPathComponent:@"build.zip"];

// 기존 폴더 삭제
// Delete existing folder
[self deleteFolderIfExists:updatedDir];
// 다운로드 받을 폴더 생성
// Create download folder
[[NSFileManager defaultManager] createDirectoryAtPath:updatedDir withIntermediateDirectories:YES attributes:nil error:nil];

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
Expand All @@ -106,27 +106,27 @@ - (void)updateBundle:(NSString *)bundleId zipUrl:(NSURL *)zipUrl completion:(voi

NSFileManager *fileManager = [NSFileManager defaultManager];

// 기존 파일 제거
// Remove existing file
if ([fileManager fileExistsAtPath:zipFilePath]) {
[fileManager removeItemAtPath:zipFilePath error:nil];
}

// 다운로드된 파일 이동
// Move downloaded file
NSError *moveError;
if (![fileManager moveItemAtURL:location toURL:[NSURL fileURLWithPath:zipFilePath] error:&moveError]) {
NSLog(@"Failed to save data: %@", moveError);
if (completion) completion(NO);
return;
}

// 압축 해제
// Extract zip
if (![self extractZipFileAtPath:zipFilePath toDestination:updatedDir]) {
NSLog(@"Failed to extract zip file.");
if (completion) completion(NO);
return;
}

// 번들 파일 탐색 (index.ios.bundle)
// Search for bundle file (index.ios.bundle)
NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:updatedDir];
NSString *filename = nil;
for (NSString *file in enumerator) {
Expand Down Expand Up @@ -189,7 +189,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
NSURLSessionDownloadTask *task = (NSURLSessionDownloadTask *)object;
if (task.countOfBytesExpectedToReceive > 0) {
double progress = (double)task.countOfBytesReceived / (double)task.countOfBytesExpectedToReceive;
NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000; // 밀리초 단위
NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000; // In milliseconds
if ((currentTime - self.lastUpdateTime) >= 100 || progress >= 1.0) {
self.lastUpdateTime = currentTime;
[self sendEventWithName:@"onProgress" body:@{@"progress": @(progress)}];
Expand Down

0 comments on commit 2d329e3

Please sign in to comment.