Skip to content

Commit

Permalink
fix: Error described in Dadoum#29
Browse files Browse the repository at this point in the history
  • Loading branch information
CI committed Apr 4, 2024
1 parent 7f58c33 commit 851ad55
Showing 1 changed file with 45 additions and 50 deletions.
95 changes: 45 additions & 50 deletions source/sideload/sign.d
Original file line number Diff line number Diff line change
Expand Up @@ -81,69 +81,66 @@ Tuple!(PlistDict, PlistDict) sign(
size_t stepCount = subBundles.length + 2;
const double stepSize = 1.0 / stepCount;

auto subBundlesTask = task({
foreach (subBundle; parallel(subBundles)) {
auto bundleFiles = subBundle.sign(
identity,
provisioningProfiles,
(double progress) => addProgress(progress * stepSize),
teamId,
sha1HasherParallel.get(),
sha2HasherParallel.get()
);
auto subBundlePath = subBundle.bundleDir;
foreach (subBundle; parallel(subBundles)) {
auto bundleFiles = subBundle.sign(
identity,
provisioningProfiles,
(double progress) => addProgress(progress * stepSize),
teamId,
sha1HasherParallel.get(),
sha2HasherParallel.get()
);
auto subBundlePath = subBundle.bundleDir;

auto bundleFiles1 = bundleFiles[0];
auto bundleFiles2 = bundleFiles[1];
auto bundleFiles1 = bundleFiles[0];
auto bundleFiles2 = bundleFiles[1];

auto subFolder = subBundlePath.relativePath(/+ base +/ bundleFolder);
auto subFolder = subBundlePath.relativePath(/+ base +/ bundleFolder);

void reroot(ref PlistDict dict, ref PlistDict subDict) {
auto iter = subDict.iter();
void reroot(ref PlistDict dict, ref PlistDict subDict) {
auto iter = subDict.iter();

string key;
Plist element;
string key;
Plist element;

synchronized {
while (iter.next(element, key)) {
dict[subFolder.buildPath(key)] = element.copy();
}
synchronized {
while (iter.next(element, key)) {
dict[subFolder.buildPath(key)] = element.copy();
}
}
reroot(files, bundleFiles1);
reroot(files2, bundleFiles2);
}
reroot(files, bundleFiles1);
reroot(files2, bundleFiles2);

void addFile(string subRelativePath) {
ubyte[] sha1 = new ubyte[](20);
ubyte[] sha2 = new ubyte[](32);
void addFile(string subRelativePath) {
ubyte[] sha1 = new ubyte[](20);
ubyte[] sha2 = new ubyte[](32);

auto localHasher1 = sha1HasherParallel.get();
auto localHasher2 = sha2HasherParallel.get();
auto localHasher1 = sha1HasherParallel.get();
auto localHasher2 = sha2HasherParallel.get();

auto hashPairs = [tuple(localHasher1, sha1), tuple(localHasher2, sha2)];
auto hashPairs = [tuple(localHasher1, sha1), tuple(localHasher2, sha2)];

scope MmFile memoryFile = new MmFile(subBundle.bundleDir.buildPath(subRelativePath));
ubyte[] fileData = cast(ubyte[]) memoryFile[];
scope MmFile memoryFile = new MmFile(subBundle.bundleDir.buildPath(subRelativePath));
ubyte[] fileData = cast(ubyte[]) memoryFile[];

foreach (hashCouple; parallel(hashPairs)) {
auto localHasher = hashCouple[0];
auto sha = hashCouple[1];
sha[] = localHasher.process(fileData)[];
}
foreach (hashCouple; parallel(hashPairs)) {
auto localHasher = hashCouple[0];
auto sha = hashCouple[1];
sha[] = localHasher.process(fileData)[];
}

synchronized {
files[subFolder.buildPath(subRelativePath)] = sha1.pl;
files2[subFolder.buildPath(subRelativePath)] = dict(
"hash", sha1,
"hash2", sha2
);
}
synchronized {
files[subFolder.buildPath(subRelativePath)] = sha1.pl;
files2[subFolder.buildPath(subRelativePath)] = dict(
"hash", sha1,
"hash2", sha2
);
}
addFile("_CodeSignature".buildPath("CodeResources"));
addFile(subBundle.appInfo["CFBundleExecutable"].str().native());
}
});
subBundlesTask.executeInNewThread();
addFile("_CodeSignature".buildPath("CodeResources"));
addFile(subBundle.appInfo["CFBundleExecutable"].str().native());
}

log.debugF!"Signing bundle %s..."(baseName(bundleFolder));

Expand Down Expand Up @@ -234,8 +231,6 @@ Tuple!(PlistDict, PlistDict) sign(
// too lazy yet to add better progress tracking
addProgress(stepSize);

subBundlesTask.yieldForce();

log.debug_("Making CodeResources...");
string codeResources = dict(
"files", files.copy(),
Expand Down

0 comments on commit 851ad55

Please sign in to comment.