Bugfix 2788 by kalkwarf · Pull Request #2796 · Carthage/Carthage · GitHub
Skip to content

Bugfix 2788 - #2796

Merged
mdiep merged 6 commits into
Carthage:masterfrom
kalkwarf:bugfix-2788
May 28, 2019
Merged

mdiep merged 6 commits into
Carthage:masterfrom
kalkwarf:bugfix-2788

Conversation

@kalkwarf

Copy link
Copy Markdown
Contributor

When stripping frameworks, copy the source into a temporary directory, process it there, and then move it back.

This is a rework of my previous PR, which didn't actually do what I thought it did.

Comment thread Source/CarthageKit/Xcode.swift Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to unnest these:

  return createTempDir
     .flatMap(.merge) { temp in
       copyItem(binaryURL, temp)
     }
     .flatMap(.merge) { workspace in
       strip(workspace, keepingArchitectures)
     }
     .flatMap(.merge) { workspace in
       replace(binaryURL, workspace)
     }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Comment thread Source/CarthageKit/Xcode.swift Outdated
return architecturesInPackage(binaryURL)
.filter { !keepingArchitectures.contains($0) }
.flatMap(.concat) { stripArchitecture(binaryURL, $0) }
let fileManager = FileManager().reactive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use FileManager.default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember the specific details, but there is (was?) a concurrency issue with the default FileManager.

Ah, here it is:

https://useyourloaf.com/blog/nsfilemanager-defaultmanager-is-not-thread-safe/

and once again, I know things that are no longer true. :-) I'll update it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!


public func replaceItem(at originalItemURL: URL, withItemAt newItemURL: URL) -> SignalProducer<(), CarthageError> {
do {
guard (try FileManager().replaceItemAt(originalItemURL, withItemAt: newItemURL, backupItemName: nil, options: .usingNewMetadataOnly)) != nil else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this before, but this should be using self.base, not FileManager()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. You're right. Stand by…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

return fileManager.replaceItem(at: original, withItemAt: modified)
}

return createTempDir

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a comment here that explains why we're going through the trouble of copying/stripping/replacing instead of just stripping?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@mdiep

mdiep commented May 28, 2019

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants