Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit b8eed11

Browse files
committed
delete before unzipping
1 parent e29ea84 commit b8eed11

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CodePushPackage.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,16 @@ + (void)downloadPackage:(NSDictionary *)updatePackage
228228
NSString * unzippedFolderPath = [CodePushPackage getUnzippedFolderPath];
229229
NSMutableDictionary * mutableUpdatePackage = [updatePackage mutableCopy];
230230
if (isZip) {
231-
NSError *nonFailingError = nil;
231+
if ([[NSFileManager defaultManager] fileExistsAtPath:unzippedFolderPath]) {
232+
[[NSFileManager defaultManager] removeItemAtPath:unzippedFolderPath
233+
error:&error];
234+
if (error) {
235+
failCallback(error);
236+
return;
237+
}
238+
}
232239

240+
NSError *nonFailingError = nil;
233241
[SSZipArchive unzipFileAtPath:downloadFilePath
234242
toDestination:unzippedFolderPath];
235243
[[NSFileManager defaultManager] removeItemAtPath:downloadFilePath

Examples/CodePushDemoApp/iOS/CodePushDemoApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
<key>NSLocationWhenInUseUsageDescription</key>
4545
<string></string>
4646
<key>CodePushDeploymentKey</key>
47-
<string>deployment-key-here</string>
47+
<string>5c73310a-cc93-4aa5-bf9f-81c6b648232c</string>
4848
</dict>
4949
</plist>

android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ public static void unzipFile(File zipFile, String destination) throws IOExceptio
152152
ZipEntry entry;
153153

154154
File destinationFolder = new File(destination);
155-
if (!destinationFolder.exists()) {
156-
destinationFolder.mkdirs();
155+
if (destinationFolder.exists()) {
156+
deleteDirectory(destinationFolder);
157157
}
158+
159+
destinationFolder.mkdirs();
158160

159161
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
160162
while ((entry = zipStream.getNextEntry()) != null) {

0 commit comments

Comments
 (0)