Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
support t2 macs (#41)
Browse files Browse the repository at this point in the history
* image t2 macs - update error handling

* only process whole disk disappear

* spelling
  • Loading branch information
tburgin authored Aug 1, 2018
1 parent 6951e0b commit 51b0acd
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 211 deletions.
1 change: 0 additions & 1 deletion Common/Disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@property(readonly, nonatomic) NSString *volName;
@property(readonly, nonatomic) NSString *volKind;
@property(readonly, nonatomic) NSString *mediaName;
@property(readonly, nonatomic) NSString *mediaContent;
@property(readonly, nonatomic) BOOL isInternal;
@property(readonly, nonatomic) BOOL isWhole;
@property(readonly, nonatomic) BOOL isNetwork;
Expand Down
3 changes: 0 additions & 3 deletions Common/Disk.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict {
_volName = dict[(__bridge NSString *)kDADiskDescriptionVolumeNameKey];
_volKind = dict[(__bridge NSString *)kDADiskDescriptionVolumeKindKey];
_mediaName = dict[(__bridge NSString *)kDADiskDescriptionMediaNameKey];
_mediaContent = dict[(__bridge NSString *)kDADiskDescriptionMediaContentKey];
_diskSize = dict[(__bridge NSString *)kDADiskDescriptionMediaSizeKey];
_protocol = dict[(__bridge NSString *)kDADiskDescriptionDeviceProtocolKey];
_isWhole = [dict[(__bridge NSString *)kDADiskDescriptionMediaWholeKey] boolValue];
Expand Down Expand Up @@ -61,7 +60,6 @@ - (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:self.volName forKey:@"volName"];
[coder encodeObject:self.volKind forKey:@"volKind"];
[coder encodeObject:self.mediaName forKey:@"mediaName"];
[coder encodeObject:self.mediaContent forKey:@"mediaContent"];
[coder encodeObject:self.diskSize forKey:@"diskSize"];
[coder encodeObject:self.protocol forKey:@"protocol"];
[coder encodeObject:@(self.isWhole) forKey:@"isWhole"];
Expand All @@ -77,7 +75,6 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
_volName = [decoder decodeObjectOfClass:[NSString class] forKey:@"volName"];
_volKind = [decoder decodeObjectOfClass:[NSString class] forKey:@"volKind"];
_mediaName = [decoder decodeObjectOfClass:[NSString class] forKey:@"mediaName"];
_mediaContent = [decoder decodeObjectOfClass:[NSString class] forKey:@"mediaContent"];
_diskSize = [decoder decodeObjectOfClass:[NSNumber class] forKey:@"diskSize"];
_protocol = [decoder decodeObjectOfClass:[NSString class] forKey:@"protocol"];
_isWhole = [[decoder decodeObjectOfClass:[NSNumber class] forKey:@"isWhole"] boolValue];
Expand Down
9 changes: 4 additions & 5 deletions Common/RestorProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@
- (void)verifyingPercentage:(NSUInteger)percent;

/*
Notifies the UI that an error has occurred and imaging has stopped.
@param error An error object containing details of the error that occurred.
Notifies the UI that inverting has started.
*/
- (void)errorOccurred:(NSError *)error;
- (void)invertingStarted;

/*
Notifies the UI that imaging has completed and ASR has exited.
@param success YES if ASR exited with 0.
@param error An error object containing details of the error that occurred.
*/
- (void)imageAppliedSuccess:(BOOL)success;
- (void)imageAppliedSuccess:(BOOL)success error:(NSError *)error;

@end
9 changes: 8 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ DEPENDENCIES:
- MOLAuthenticatingURLSession
- MOLXPCConnection

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- MOLAuthenticatingURLSession
- MOLCertificate
- MOLCodesignChecker
- MOLXPCConnection

SPEC CHECKSUMS:
MOLAuthenticatingURLSession: c238aa1c9a7b1077eb39a6f40204bfe76a7d204e
MOLCertificate: c999513316d511c69f290fbf313dfe8dca4ad592
Expand All @@ -19,4 +26,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 5cf4b07f7d175476d2cc6f41208074b1933af454

COCOAPODS: 1.4.0
COCOAPODS: 1.5.3
48 changes: 0 additions & 48 deletions Restor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@
0DE120391DF5D13300ABAC7E /* Frameworks */,
0DE1203A1DF5D13300ABAC7E /* Resources */,
0DE120861DF5D68000ABAC7E /* CopyFiles */,
4EABD2DDB9043AF4D6CBCC84 /* [CP] Embed Pods Frameworks */,
D9C29F6DD958B285BAAADCE2 /* [CP] Copy Pods Resources */,
0DE1208F1DF6088700ABAC7E /* Reset Info.plist */,
);
buildRules = (
Expand All @@ -341,7 +339,6 @@
0DE1206F1DF5D49100ABAC7E /* Sources */,
0DE120701DF5D49100ABAC7E /* Frameworks */,
0DE120711DF5D49100ABAC7E /* CopyFiles */,
37E4C1CE4524B834E53D48F5 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -447,21 +444,6 @@
shellPath = /bin/sh;
shellScript = "sh ./Common/requirement_builder.sh reset-app\nsh ./Common/requirement_builder.sh reset-helper";
};
37E4C1CE4524B834E53D48F5 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-com.google.corp.restord/Pods-com.google.corp.restord-resources.sh\"\n";
showEnvVarsInLog = 0;
};
4568AE51EB71AE55CEB0C12C /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -480,21 +462,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
4EABD2DDB9043AF4D6CBCC84 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Restor/Pods-Restor-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
A371B301FC3DB0BDEC89BDE7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -513,21 +480,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
D9C29F6DD958B285BAAADCE2 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Restor/Pods-Restor-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ - (NSString *)imagingStatusString {
return NSLocalizedString(@"Starting...", nil);
case ImagingStageImaging:
return NSLocalizedString(@"Imaging...", nil);
case ImagingStageInverting:
return NSLocalizedString(@"Inverting...", nil);
case ImagingStageVerifying:
return NSLocalizedString(@"Verifying...", nil);
case ImagingStageComplete:
Expand All @@ -56,6 +58,7 @@ - (float)progressPercent {
case ImagingStageError:
return 0.0;
case ImagingStageImaging:
case ImagingStageInverting:
return self.imagingSession.percentComplete * kImagingRatioOfTotal;
case ImagingStageVerifying:
return (kImagingRatioOfTotal * 100) +
Expand Down
29 changes: 20 additions & 9 deletions Restor/Controllers/ViewControllers/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ - (void)createDiskWatcher {

dispatch_async(dispatch_get_main_queue(), ^{
STRONGIFY(self);
if ([self.connectedDisks containsObject:disk]) return;
[[self mutableArrayValueForKey:@"connectedDisks"] addObject:disk];
[self.collectionView reloadData];

Expand All @@ -88,17 +89,27 @@ - (void)createDiskWatcher {
};
self.diskWatcher.disappearCallback = ^(Disk *disk) {
STRONGIFY(self);
ImagingSession *is = self.imagingSessions[disk.bsdName];
self.imagingSessions[disk.bsdName] = nil;

dispatch_sync(dispatch_get_main_queue(), ^{
STRONGIFY(self);
[[self mutableArrayValueForKey:@"connectedDisks"] removeObject:disk];
[self.collectionView reloadData];
});
// Only proccess whole disks
if (!disk.isWhole) return;

// Remove all leaf disks
for (Disk *connectedDisk in self.connectedDisks) {
if (![connectedDisk.bsdName hasPrefix:disk.bsdName]) continue;

ImagingSession *is = self.imagingSessions[connectedDisk.bsdName];
self.imagingSessions[connectedDisk.bsdName] = nil;

dispatch_sync(dispatch_get_main_queue(), ^{
STRONGIFY(self);
[[self mutableArrayValueForKey:@"connectedDisks"] removeObject:connectedDisk];
[self.collectionView reloadData];
});

// Do this after the UI updates to avoid breaking KVO.
[is cancel];
}

// Do this after the UI updates to avoid breaking KVO.
[is cancel];
};
[self.diskWatcher beginWatching];
}
Expand Down
4 changes: 2 additions & 2 deletions Restor/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.6</string>
<string>1.7</string>
<key>CFBundleVersion</key>
<string>1.6</string>
<string>1.7</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
1 change: 1 addition & 0 deletions Restor/Model/ImagingSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
typedef NS_ENUM(NSInteger, ImagingStage) {
ImagingStageNotStarted,
ImagingStageImaging,
ImagingStageInverting,
ImagingStageVerifying,
ImagingStageComplete,
ImagingStageError,
Expand Down
12 changes: 4 additions & 8 deletions Restor/Model/ImagingSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ @interface ImagingSession ()
@property(readwrite) NSUInteger percentComplete;
@property(readwrite) ImagingStage imagingStage;
@property(readwrite) NSError *lastError;
@property NSError *error;
@end

@implementation ImagingSession
Expand Down Expand Up @@ -70,31 +69,28 @@ - (void)imagingPercentage:(NSUInteger)percent {
dispatch_async(dispatch_get_main_queue(), ^{
self.imagingStage = ImagingStageImaging;
self.percentComplete = percent;
self.error = nil;
});
}

- (void)verifyingPercentage:(NSUInteger)percent {
dispatch_async(dispatch_get_main_queue(), ^{
self.imagingStage = ImagingStageVerifying;
self.percentComplete = percent;
self.error = nil;
});
}

- (void)errorOccurred:(NSError *)error {
- (void)invertingStarted {
dispatch_async(dispatch_get_main_queue(), ^{
self.imagingStage = ImagingStageError;
self.error = error;
self.imagingStage = ImagingStageInverting;
});
}

- (void)imageAppliedSuccess:(BOOL)success {
- (void)imageAppliedSuccess:(BOOL)success error:(NSError *)error {
dispatch_async(dispatch_get_main_queue(), ^{
if (!success) {
self.imagingStage = ImagingStageError;
self.percentComplete = 0;
self.lastError = self.error;
self.lastError = error;
} else {
self.imagingStage = ImagingStageComplete;
self.percentComplete = 100;
Expand Down
Loading

0 comments on commit 51b0acd

Please sign in to comment.