Skip to content

Reduced memory usage by reading files using extractBufferedDataFromFile…#28

Merged
abbeycode merged 5 commits intoabbeycode:masterfrom
brendand:master
Feb 14, 2016
Merged

Reduced memory usage by reading files using extractBufferedDataFromFile…#28
abbeycode merged 5 commits intoabbeycode:masterfrom
brendand:master

Conversation

@brendand
Copy link
Copy Markdown
Contributor

… instead of readFile. Addresses #27

Files were previously read whole into memory and then written out. This change streams them instead, reducing the amount of memory required to unzip files.

…le instead of readFile. Addresses abbeycode#27

Signed-off-by: Brendan Duddridge <brendand@gmail.com>
Comment thread Source/UZKArchive.m
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm curious what the reason is for this change. Is it a multithreading concern?

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.

Yes, I think I read somewhere that it was best to create your own NSFileManager if you were doing anything in the background.

@abbeycode
Copy link
Copy Markdown
Owner

I had one question I commented inline, but also these general concerns:

  • Please fix what broke the build. It looks like a unit test is failing
  • Please replace tabs with spaces (4 spaces per tab)

Take a look at the above, and then I'll take a closer look at the rest of your changes.

@brendand
Copy link
Copy Markdown
Contributor Author

brendand commented Feb 2, 2016

Sorry, I guess I have tabs set instead of spaces in Xcode. Hopefully if I change that it won't screw up my own version control. I think it was something to do with the password not being provided. I didn't change any of that code and it looked like all other tests passed.

Wasn't passing up the proper error code when unzipping a password protected archive without providing a password. Also wasn't deleting the directory we created if the unarchiving failed. All tests pass now.

Also had to add "import UnzipKit" to WriteDataTests.swift. Failed to compile otherwise.

Signed-off-by: Brendan Duddridge <brendand@gmail.com>
@abbeycode
Copy link
Copy Markdown
Owner

Switching your Xcode preference will affect new edits you make, but for now can you please do a find and replace (find \t and replace with 4 spaces). Sorry, it's a nitpick, but it'll keep the code more consistent.

Comment thread Source/UZKArchive.m Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please fix this typo: defalatedDirectoryURL instead of deflatedDirectoryURL

@abbeycode
Copy link
Copy Markdown
Owner

I've added some inline comments, but this is looking good. Thanks again!

Signed-off-by: Brendan Duddridge <brendand@gmail.com>
@abbeycode
Copy link
Copy Markdown
Owner

I've left a couple more inline comments. Thanks for sticking with it. We're close; I can feel it!

I can replace the tabs with spaces when I merge, if you'd prefer to change your Xcode preference back.

@brendand
Copy link
Copy Markdown
Contributor Author

brendand commented Feb 3, 2016

Oops. I did do a search and replace and have set Xcode to use spaces. Not sure why it didn't change though. I'll get to these issues later as I have to go out to demo the next version of my app to an iOS dev meetup. I'll get rid of that dataLength var if it's no longer needed and add the file handle check.

Signed-off-by: Brendan Duddridge <brendand@gmail.com>
@brendand
Copy link
Copy Markdown
Contributor Author

Do you think this is suitable to merge into master now?

Comment thread Source/UZKArchive.m Outdated


if (!deflatedFileHandle) {
[self assignError:&strongError code:UZKErrorCodeFileHandleCreate
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think it's necessary to create a new error code for this case. Just use the UZKErrorCodeOutputError code used elsewhere in the method.

@abbeycode
Copy link
Copy Markdown
Owner

Hey, sorry, I missed the commit you pushed. I took a look and made an inline comment. Take care of that, then I'll fix the tab-to-space conversion and merge manually.

…deOutputError instead.

Signed-off-by: Brendan Duddridge <brendand@gmail.com>
@brendand
Copy link
Copy Markdown
Contributor Author

ok, fixed. Hopefully it's ok now.

@abbeycode abbeycode merged commit d13486e into abbeycode:master Feb 14, 2016
abbeycode added a commit that referenced this pull request Feb 14, 2016
@abbeycode
Copy link
Copy Markdown
Owner

All set now. Thanks for suggesting and writing this. Awesome job!

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