delete before unzipping

This commit is contained in:
Geoffrey Goh
2016-02-05 14:13:02 -08:00
parent e29ea847e2
commit b8eed11109
3 changed files with 14 additions and 4 deletions

View File

@@ -228,8 +228,16 @@ NSString * const UnzippedFolderName = @"unzipped";
NSString * unzippedFolderPath = [CodePushPackage getUnzippedFolderPath];
NSMutableDictionary * mutableUpdatePackage = [updatePackage mutableCopy];
if (isZip) {
NSError *nonFailingError = nil;
if ([[NSFileManager defaultManager] fileExistsAtPath:unzippedFolderPath]) {
[[NSFileManager defaultManager] removeItemAtPath:unzippedFolderPath
error:&error];
if (error) {
failCallback(error);
return;
}
}
NSError *nonFailingError = nil;
[SSZipArchive unzipFileAtPath:downloadFilePath
toDestination:unzippedFolderPath];
[[NSFileManager defaultManager] removeItemAtPath:downloadFilePath

View File

@@ -44,6 +44,6 @@
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>CodePushDeploymentKey</key>
<string>deployment-key-here</string>
<string>5c73310a-cc93-4aa5-bf9f-81c6b648232c</string>
</dict>
</plist>

View File

@@ -152,9 +152,11 @@ public class FileUtils {
ZipEntry entry;
File destinationFolder = new File(destination);
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
if (destinationFolder.exists()) {
deleteDirectory(destinationFolder);
}
destinationFolder.mkdirs();
byte[] buffer = new byte[WRITE_BUFFER_SIZE];
while ((entry = zipStream.getNextEntry()) != null) {