@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implicitly detect directories when updating a fragment from a ZIP

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.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, staticshock

Maniphest Tasks: T4205

Differential Revision: https://secure.phabricator.com/D7733

+27
+27
src/applications/phragment/storage/PhragmentFragment.php
··· 162 162 $mappings[$path] = $data; 163 163 } 164 164 165 + // We need to detect any directories that are in the ZIP folder that 166 + // aren't explicitly noted in the ZIP. This can happen if the file 167 + // entries in the ZIP look like: 168 + // 169 + // * something/blah.png 170 + // * something/other.png 171 + // * test.png 172 + // 173 + // Where there is no explicit "something/" entry. 174 + foreach ($mappings as $path_key => $data) { 175 + if ($data === null) { 176 + continue; 177 + } 178 + $directory = dirname($path_key); 179 + while ($directory !== ".") { 180 + if (!array_key_exists($directory, $mappings)) { 181 + $mappings[$directory] = null; 182 + } 183 + if (dirname($directory) === $directory) { 184 + // dirname() will not reduce this directory any further; to 185 + // prevent infinite loop we just break out here. 186 + break; 187 + } 188 + $directory = dirname($directory); 189 + } 190 + } 191 + 165 192 // Adjust the paths relative to this fragment so we can look existing 166 193 // fragments up in the DB. 167 194 $base_path = $this->getPath();