Skip to content

Conversation

@MartinLau7
Copy link
Contributor

@MartinLau7 MartinLau7 commented May 31, 2019

Submit log

1. Unzip to add recovery for macOS file permissions
2. Compress add retention for macOS file permissions
3. UZKFileInfo Add Permission Attributes

Test Code

NSString *zipFilePath = @"/Users/martin/
UZKArchive *archive = [[UZKArchive alloc] initWithPath:zipFilePath error:&archiveError];
if (archiveError) {
        return;
}
NSDictionary *infoDict = [[NSFileManager defaultManager] attributesOfItemAtPath:[@"your file" stringByAppendingPathComponent:obj] error:nil];
NSNumber *mode = [infoDict objectForKey:NSFilePosixPermissions];

NSData *fileData = ...;
if (![archive writeData:fileData filePath:@"zip file path" posixPermissions:[mode unsignedLongValue] error:nil]) {
       NSLog(@"zip file error");
}

Copy link
Owner

@abbeycode abbeycode left a comment

Choose a reason for hiding this comment

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

Martin, I'd first like to thank you for contributing this PR! It's a really awesome idea for the framework, and I'm glad you worked out all the details for how best to implement it. You even submitted the request to the right branch! There are some changes I'd like to see before we merge, though. I made some comments inline for context, but I've created tasks in this comment for the bigger-picture changes.

  • I'd like to leave permissions to only be specified in the most detailed overload. All the other overloads can pass 0. This way we don't break any existing code. So in the header, there should only be two changes (a new declaration for writeData and one for writeIntoBuffer, which add the permissions parameter)
  • Please revert your changes to the project and scheme (as I think they're what's breaking the build)
  • Make sure the Travis CI build is passing (it makes sure all the code compiles, and tests pass)
  • Thanks for adding test code in your PR description, but would you be able to add some unit test cases? It would be great if you could add a PermissionsTests class (preferably in Swift), with methods to test the cases below. There are tons of examples for how I'm testing this framework in the other test cases, and I'll be glad to help with any questions you have.
    • Using each of the overloads that doesn't specify permissions creates files on disk with default permissions like what currently happens (preserve backwards-compatibility)
    • Creating a new archive with specific non-default permissions and then reading it in (same file, different UZKArchive instance) returns the expected values in the UZKFileInfo instances
    • Extracting an archive with non-default permissions results in those permissions in the extracted files

@abbeycode abbeycode changed the title add posix permissions support Support reading and writing of POSIX permissions May 31, 2019
@abbeycode abbeycode added this to the 1.9 milestone May 31, 2019
@MartinLau7
Copy link
Contributor Author

First of all, I am sorry that I have not made the correct modifications in the submitted code, I will improve these errors in the future.

@MartinLau7 MartinLau7 closed this Jun 3, 2019
@abbeycode
Copy link
Owner

Hey Martin, no big deal, this is part of the process for a pull request. Let's work on this together. The PR isn't final - you can push more changes to your branch, and it'll update.

@abbeycode abbeycode reopened this Jun 3, 2019
@abbeycode abbeycode changed the title Support reading and writing of POSIX permissions Support archival of POSIX permissions Jun 3, 2019
@MartinLau7
Copy link
Contributor Author

@abbeycode There is currently a change in the package, I seem to be destroying the version of Xcode, it has been upgraded to Xcode 10.2

@abbeycode abbeycode changed the title Support archival of POSIX permissions Support archival and restoration of POSIX permissions Jun 4, 2019
@abbeycode
Copy link
Owner

Please let me know when you're done with your changes and are ready for me to review again. Also, make sure you review your changes in the "Files changed" tab when you're done, so they only contain changes you intended to make (not making whitespace changes to code you otherwise didn't touch).

Also, if you're having trouble understanding any of my comments, please let me know, and I can try to rephrase, or go into more detail.

@abbeycode
Copy link
Owner

I just saw your Xcode 10.2 comment. The version of Xcode you use shouldn't matter, so long as you don't commit any upgrade checks or use APIs only available in newer versions of the frameworks (which Xcode shouldn't let you do unless you change the deployment target, which you shouldn't change either :)

Copy link
Contributor Author

@MartinLau7 MartinLau7 left a comment

Choose a reason for hiding this comment

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

Please let me know when you're done with your changes and are ready for me to review again. Also, make sure you review your changes in the "Files changed" tab when you're done, so they only contain changes you intended to make (not making whitespace changes to code you otherwise didn't touch).

Also, if you're having trouble understanding any of my comments, please let me know, and I can try to rephrase, or go into more detail.

<0031d57>
I have already submitted a new code and still need your check. I will continue if I need to modify it.

How can I conduct a new review?

@abbeycode
Copy link
Owner

Did you see the list of requests I made in the initial review comment?

@MartinLau7
Copy link
Contributor Author

Did you see the list of requests I made in the initial review comment?

Yes, I see this problem now, because I have an exception in the code version of the workbench that I can't resubmit, I need to close the Pull Request later, until I rearrange and create a new Pull Request. What do you think?

@abbeycode
Copy link
Owner

You don't need to close this PR, and you don't need to use a different version of Xcode. Just back out the changes you made to the project.pbxproj and UnzipKit.xcscheme files that aren't directly necessary for your change. You can use Xcode to this, if you view the changes from the v1.9 branch. Once you've backed out those changes, you can push to this branch again, and the PR will update.

2. Remove the permission to set the default 0644U, now the default is 0755U
3. Fix the damage caused by Xcode
4. Add to Test Code and Test File
5. Add the writeFile function
@MartinLau7
Copy link
Contributor Author

You don't need to close this PR, and you don't need to use a different version of Xcode. Just back out the changes you made to the project.pbxproj and UnzipKit.xcscheme files that aren't directly necessary for your change. You can use Xcode to this, if you view the changes from the v1.9 branch. Once you've backed out those changes, you can push to this branch again, and the PR will update.

@abbeycode Since Xcode breaks git, it is not considered to turn off PR before. Now I have resubmitted and passed the Travis CI build, I will continue to modify if there are new issues.

Copy link
Owner

@abbeycode abbeycode left a comment

Choose a reason for hiding this comment

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

Thanks for sticking with this process, Martin. It's starting to shape up! It seems like there's a lot of criticism in this review, but there are only a few bigger things. Most of my comments are minor nitpicks.

@abbeycode abbeycode changed the base branch from v1.9 to pr84 June 20, 2019 12:47
@abbeycode
Copy link
Owner

abbeycode commented Jun 20, 2019

I've created a new branch, pr84, to merge your PR into, for me to then work on it further. Can you please rebase your changes on that branch? I merged a different PR just now, that made two single-line fixes. After your rebase I'll merge into that branch and create a new PR for you to review once I've implemented the changes we discussed. You can keep the "v1.9" branch name in your repo. That shouldn't matter.

2. Remove the permission to set the default 0644U, now the default is 0755U
3. Fix the damage caused by Xcode
4. Add to Test Code and Test File
5. Add the writeFile function
@MartinLau7
Copy link
Contributor Author

MartinLau7 commented Jun 21, 2019

I've created a new branch, pr84, to merge your PR into, for me to then work on it further. Can you please rebase your changes on that branch? I merged a different PR just now, that made two single-line fixes. After your rebase I'll merge into that branch and create a new PR for you to review once I've implemented the changes we discussed. You can keep the "v1.9" branch name in your repo. That shouldn't matter.

I have rebase to "PR84", but there are some merge errors, I think I need to modify it in my free time, I will add some new code to optimize the "UZKFileInfo - isDirectory" implementation, then I will commit again.

@abbeycode
Copy link
Owner

What are you changing in the isDirectory implementation?

Also, the changes I'm asking you to rebase into your branch are super simple: just a single commit affecting two lines (link here). Just resolve the rebase conflict using your version of UZKArchive.m, and before you commit make that same change, replacing UZKCompressionMethodDefault with method on those two lines.

2. Add the UZKFileInfo property (isSymLink, isResourceFork)
3. UZKFileInfo isDirectory attribute value takes a new judgment function
4. Rebase branch to "PR84"
@MartinLau7
Copy link
Contributor Author

MartinLau7 commented Jun 24, 2019

I have rebased to "PR84" and modified the previous error.
In the new commit I modified the isDirectory code to make it better for type judgment, and I added "isSymLink" and "isResourceFork".
"isSymLink" can determine if the file is a symbolic link.
"isResourceFork" can help us decide whether to decompress the "__MACOSX" content.

@MartinLau7
Copy link
Contributor Author

MartinLau7 commented Jun 24, 2019

The new commit seems to have changed something in Xcode, and I have avoided submitting Xcode files as much as possible. This makes me very annoyed, I need your help to get it back to the original version.

@abbeycode
Copy link
Owner

Martin, I would like to merge this PR into the pr84 branch I created and make the remaining changes I'd like to see there myself. What would you like to get back to the original version, and what do you mean by the original version? There are ways in Git and in Xcode to checkout an older revision of a file over your working copy (or to compare its contents to the current revision), and then you can use Xcode to select which changes you want to commit (if any).

I'm going to squash and merge your PR and will start making my own commits on top. I'll open up a new PR and we can continue the discussion there.

@abbeycode abbeycode merged commit 8c73785 into abbeycode:pr84 Jun 24, 2019
abbeycode added a commit that referenced this pull request Jun 24, 2019
@abbeycode abbeycode mentioned this pull request Jun 25, 2019
abbeycode pushed a commit that referenced this pull request Jun 27, 2019
Adds support for archival and restoration of POSIX permissions, finishing the process that started across PRs #84 and #86
@abbeycode
Copy link
Owner

PR #87 was merged into the v1.9 branch, including these changes

abbeycode added a commit that referenced this pull request Jun 27, 2019
abbeycode added a commit that referenced this pull request Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants