Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15388773
D7869.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7869.diff
View Options
Index: src/infrastructure/celerity/CelerityResourceController.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceController.php
+++ src/infrastructure/celerity/CelerityResourceController.php
@@ -16,10 +16,6 @@
return false;
}
- private function getDiskPath($to_resource = null) {
- return $this->getRootDirectory().$to_resource;
- }
-
protected function serveResource($path, $package_hash = null) {
// Sanity checking to keep this from exposing anything sensitive, since it
// ultimately boils down to disk reads.
@@ -41,18 +37,18 @@
return $this->makeResponseCacheable(new Aphront304Response());
}
+ $map = CelerityResourceMap::getInstance();
+
if ($package_hash) {
- $map = CelerityResourceMap::getInstance();
- $paths = $map->resolvePackage($package_hash);
- if (!$paths) {
+ $resource_names = $map->getResourceNamesForPackageHash($package_hash);
+ if (!$resource_names) {
return new Aphront404Response();
}
try {
$data = array();
- foreach ($paths as $package_path) {
- $disk_path = $this->getDiskPath($package_path);
- $data[] = Filesystem::readFile($disk_path);
+ foreach ($resource_names as $resource_name) {
+ $data[] = $map->getResourceDataForName($resource_name);
}
$data = implode("\n\n", $data);
} catch (Exception $ex) {
@@ -60,8 +56,7 @@
}
} else {
try {
- $disk_path = $this->getDiskPath($path);
- $data = Filesystem::readFile($disk_path);
+ $data = $map->getResourceDataForName($path);
} catch (Exception $ex) {
return new Aphront404Response();
}
Index: src/infrastructure/celerity/CelerityResourceMap.php
===================================================================
--- src/infrastructure/celerity/CelerityResourceMap.php
+++ src/infrastructure/celerity/CelerityResourceMap.php
@@ -90,7 +90,13 @@
return $packaged;
}
- public function resolvePackage($package_hash) {
+ public function getResourceDataForName($resource_name) {
+ $root = phutil_get_library_root('phabricator');
+ $root = dirname($root).'/webroot/';
+ return Filesystem::readFile($root.$resource_name);
+ }
+
+ public function getResourceNamesForPackageHash($package_hash) {
$package = idx($this->packageMap['packages'], $package_hash);
if (!$package) {
return null;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 4:22 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704395
Default Alt Text
D7869.diff (2 KB)
Attached To
Mode
D7869: Improve package resolution APIs on CelerityResourceMap
Attached
Detach File
Event Timeline
Log In to Comment