Page MenuHomePhabricator

Implicitly detect directories when updating a fragment from a ZIP
ClosedPublic

Authored by hach-que on Dec 7 2013, 3:17 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 15, 8:59 AM
Unknown Object (File)
Fri, Apr 12, 9:39 AM
Unknown Object (File)
Sun, Mar 31, 10:08 PM
Unknown Object (File)
Mar 19 2024, 9:08 AM
Unknown Object (File)
Mar 5 2024, 5:04 PM
Unknown Object (File)
Feb 13 2024, 11:23 PM
Unknown Object (File)
Feb 10 2024, 9:31 PM
Unknown Object (File)
Feb 2 2024, 11:55 PM

Details

Summary

This fixes the update-from-ZIP functionality so that it will automatically detect directories in the ZIP that do not have explicit entries. Some ZIP programs do not create directory entries explicitly, so if we fail to do this then there's no way for users to access the sub-fragments (even though they exist, there is no directory fragment to click through).

Test Plan

Created and updated fragments from a ZIP that had implicit directories in it.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

hach-que updated this revision to Unknown Object (????).Dec 7 2013, 6:19 AM

Recurse up the directory tree when performing this check in case we have:

  • something.exe
  • blah/hello/path.txt
src/applications/phragment/storage/PhragmentFragment.php
166

"in the file" -> "if the file" typo?

173

"Whether" -> "Where" typo?

hach-que updated this revision to Unknown Object (????).Dec 7 2013, 6:41 AM

Spelling

Some minor inlines.

src/applications/phragment/storage/PhragmentFragment.php
185

This is sort of dangerous because dirname('/') is / -- it never reduces to ".". We've had at least one infinite loop bug with this, where I got it wrong inside some unit test stuff.

Maybe we should implement a method like Filesystem::walkToRoot() which doesn't look at the filesystem? phutil_walk_path() or similar. I believe there would be at least one callsite in arc for it.

186–188

in_array() is O(N). I think this is a little simpler, and is O(1):

if (array_key_exists($directory, $mappings)) {
  $mappings[$directory] = null;
}

Then $directories can be removed?

hach-que updated this revision to Unknown Object (????).Dec 8 2013, 1:09 AM

Prevented infinite loop with dirname() and removed need for $directories.