From 54fe8452e52b6aa83bb7524c1ec83c73fa75eb50 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 23 Feb 2015 19:55:41 +1100 Subject: [PATCH] uploadsPath -> cms.storage.uploads.path --- CHANGELOG.md | 2 +- config/app.php | 1 + config/cms.php | 153 ++++++++++++++----------- modules/system/console/OctoberUtil.php | 22 +++- modules/system/models/File.php | 2 +- 5 files changed, 112 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df9c71e2d..e02417b86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ - Added the ability to prune Event and Request log records. * **Build 199** (2015-02-19) - - The **/uploads** directory has been moved to **/storage/app/uploads** to make way for CDN support. This directory should be moved on the file system and the config (`cms.uploadsPath`) updated. + - The **/uploads** directory has been moved to **/storage/app/uploads** to make way for CDN support. This directory should be moved on the file system and the config (`cms.storage.uploads.path`) updated. * **Build 192** (2015-02-14) - For security reasons a vague error message is shown when a user tries to sign in unsuccessfully and the setting `app.debug` is disabled. diff --git a/config/app.php b/config/app.php index ae1cd12a8..6f14c82fb 100644 --- a/config/app.php +++ b/config/app.php @@ -97,6 +97,7 @@ return array( | Available Settings: "single", "daily", "syslog" | */ + 'log' => 'single', /* diff --git a/config/cms.php b/config/cms.php index f166d8358..23d747cff 100644 --- a/config/cms.php +++ b/config/cms.php @@ -2,53 +2,6 @@ return array( - /* - |-------------------------------------------------------------------------- - | Specifies the default CMS theme. - |-------------------------------------------------------------------------- - | - | This parameter value can be overridden by the CMS back-end settings. - | - */ - - 'activeTheme' => 'demo', - - /* - |-------------------------------------------------------------------------- - | Determines which modules to load - |-------------------------------------------------------------------------- - | - | Specify which modules should be registered when using the application. - | - */ - - 'loadModules' => ['System', 'Backend', 'Cms'], - - /* - |-------------------------------------------------------------------------- - | Specific plugins to disable - |-------------------------------------------------------------------------- - | - | Specify plugin codes which will always be disabled in the application. - | - */ - - 'disablePlugins' => [], - - /* - |-------------------------------------------------------------------------- - | Prevents application updates - |-------------------------------------------------------------------------- - | - | If using composer or git to download updates to the core files, set this - | value to 'true' to prevent the update gateway from trying to download - | these files again as part of the application update process. Plugins - | and themes will still be downloaded. - | - */ - - 'disableCoreUpdates' => false, - /* |-------------------------------------------------------------------------- | Bleeding edge updates @@ -62,6 +15,17 @@ return array( 'edgeUpdates' => false, + /* + |-------------------------------------------------------------------------- + | Specifies the default CMS theme. + |-------------------------------------------------------------------------- + | + | This parameter value can be overridden by the CMS back-end settings. + | + */ + + 'activeTheme' => 'demo', + /* |-------------------------------------------------------------------------- | Back-end URI prefix @@ -86,16 +50,39 @@ return array( /* |-------------------------------------------------------------------------- - | Time to live for parsed CMS objects. + | Determines which modules to load |-------------------------------------------------------------------------- | - | Specifies the number of minutes the CMS object cache lives. After the interval - | is expired item are re-cached. Note that items are re-cached automatically when - | the corresponding template file is modified. + | Specify which modules should be registered when using the application. | */ - 'parsedPageCacheTTL' => 10, + 'loadModules' => ['System', 'Backend', 'Cms'], + + /* + |-------------------------------------------------------------------------- + | Prevents application updates + |-------------------------------------------------------------------------- + | + | If using composer or git to download updates to the core files, set this + | value to 'true' to prevent the update gateway from trying to download + | these files again as part of the application update process. Plugins + | and themes will still be downloaded. + | + */ + + 'disableCoreUpdates' => false, + + /* + |-------------------------------------------------------------------------- + | Specific plugins to disable + |-------------------------------------------------------------------------- + | + | Specify plugin codes which will always be disabled in the application. + | + */ + + 'disablePlugins' => [], /* |-------------------------------------------------------------------------- @@ -124,6 +111,19 @@ return array( 'urlCacheTtl' => 10, + /* + |-------------------------------------------------------------------------- + | Time to live for parsed CMS objects. + |-------------------------------------------------------------------------- + | + | Specifies the number of minutes the CMS object cache lives. After the interval + | is expired item are re-cached. Note that items are re-cached automatically when + | the corresponding template file is modified. + | + */ + + 'parsedPageCacheTTL' => 10, + /* |-------------------------------------------------------------------------- | Determines if the asset caching is enabled. @@ -178,26 +178,38 @@ return array( /* |-------------------------------------------------------------------------- - | Public uploads path + | Resource storage |-------------------------------------------------------------------------- | - | Specifies the public uploads path relative to the application base URL, - | or you can specify a full URL path. + | Specifies the configuration for resource storage, such as media and + | upload files. These resources are used: | + | media - generated by the media manager. + | uploads - generated by attachment model relationships. + | + | For each resource you can specify: + | + | disk - filesystem disk, as specified in filesystems.php config. + | folder - a folder prefix for storing all generated files inside. + | path - the public path relative to the application base URL, + | or you can specify a full URL path. */ - 'uploadsPath' => '/storage/app/uploads', + 'storage' => [ - /* - |-------------------------------------------------------------------------- - | Default permission mask - |-------------------------------------------------------------------------- - | - | Specifies a default file and folder permission for newly created objects. - | - */ + 'uploads' => [ + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', + ], - 'defaultMask' => ['file' => null, 'folder' => null], + 'media' => [ + 'disk' => 'local', + 'folder' => 'media', + 'path' => '/storage/app/media', + ], + + ], /* |-------------------------------------------------------------------------- @@ -227,4 +239,15 @@ return array( 'linkPolicy' => 'detect', + /* + |-------------------------------------------------------------------------- + | Default permission mask + |-------------------------------------------------------------------------- + | + | Specifies a default file and folder permission for newly created objects. + | + */ + + 'defaultMask' => ['file' => null, 'folder' => null], + ); diff --git a/modules/system/console/OctoberUtil.php b/modules/system/console/OctoberUtil.php index 41e86c072..3dc4900de 100644 --- a/modules/system/console/OctoberUtil.php +++ b/modules/system/console/OctoberUtil.php @@ -125,6 +125,8 @@ class OctoberUtil extends Command } $totalCount = 0; + $uploadsPath = Config::get('filesystems.disks.local.root', storage_path().'/app'); + $uploadsPath .= '/uploads'; /* * Recursive function to scan the directory for files beginning @@ -146,7 +148,7 @@ class OctoberUtil extends Command } }; - $purgeFunc(uploads_path()); + $purgeFunc($uploadsPath); if ($totalCount > 0) { $this->comment(sprintf('Successfully deleted %s thumbs', $totalCount)); @@ -155,4 +157,22 @@ class OctoberUtil extends Command $this->comment('No thumbs found to delete'); } } + + protected function utilPurgeUploads() + { + if (!$this->confirmToProceed('This will PERMANENTLY DELETE files in the uploads directory that do not exist in the "system_files" table.')) { + return; + } + + // @todo + } + + protected function utilPurgeOrphans() + { + if (!$this->confirmToProceed('This will PERMANENTLY DELETE files in "system_files" that do not belong to any other model.')) { + return; + } + + // @todo + } } diff --git a/modules/system/models/File.php b/modules/system/models/File.php index fb501bba1..9c1a95683 100644 --- a/modules/system/models/File.php +++ b/modules/system/models/File.php @@ -30,7 +30,7 @@ class File extends FileBase */ public function getPublicPath() { - $uploadsPath = Config::get('cms.uploadsPath', '/storage/app/uploads'); + $uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads'); if (!preg_match("/(\/\/|http|https)/", $uploadsPath)) { $uploadsPath = Request::getBasePath() . $uploadsPath;