clear rolled back package files

This commit is contained in:
Geoffrey Goh
2015-12-28 18:24:23 -08:00
parent 03e91b3ff9
commit b7f47b785a
2 changed files with 14 additions and 1 deletions

View File

@@ -475,11 +475,22 @@ NSString * const UnzippedFolderName = @"unzipped";
{
NSError *error;
NSMutableDictionary *info = [self getCurrentPackageInfo:&error];
if (error) {
return;
}
NSString *currentPackageFolderPath = [self getCurrentPackageFolderPath:&error];
if (error) {
return;
}
NSError *deleteError;
[[NSFileManager defaultManager] removeItemAtPath:currentPackageFolderPath
error:&deleteError];
if (deleteError) {
NSLog(@"Error deleting current package contents at %@", currentPackageFolderPath);
}
[info setValue:info[@"previousPackage"] forKey:@"currentPackage"];
[info removeObjectForKey:@"previousPackage"];

View File

@@ -187,6 +187,8 @@ public class CodePushPackage {
public void rollbackPackage() throws IOException {
WritableMap info = getCurrentPackageInfo();
String currentPackageFolderPath = getCurrentPackageFolderPath();
CodePushUtils.deleteDirectoryAtPath(currentPackageFolderPath);
info.putString(CURRENT_PACKAGE_KEY, CodePushUtils.tryGetString(info, PREVIOUS_PACKAGE_KEY));
info.putNull(PREVIOUS_PACKAGE_KEY);
updateCurrentPackageInfo(info);