diff options
Diffstat (limited to 'lib')
35 files changed, 546 insertions, 86 deletions
diff --git a/lib/l10n/cs_CZ.js b/lib/l10n/cs_CZ.js index c4bb85acd64..97a57585936 100644 --- a/lib/l10n/cs_CZ.js +++ b/lib/l10n/cs_CZ.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "To lze obvykle vyřešit povolením zápisu webovému serveru do konfiguračního adresáře", "See %s" : "Viz %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "To lze obvykle vyřešit %spovolením zápisu webovému serveru do konfiguračního adresáře%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Soubory aplikace \"%$1s\" (%$2s) nebyly řádně nahrazeny.", "Sample configuration detected" : "Byla detekována vzorová konfigurace", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Pravděpodobně byla zkopírována konfigurační nastavení ze vzorových souborů. Toto není podporováno a může poškodit vaši instalaci. Nahlédněte prosím do dokumentace před prováděním změn v souboru config.php", "PHP %s or higher is required." : "Je vyžadováno PHP %s nebo vyšší.", diff --git a/lib/l10n/cs_CZ.json b/lib/l10n/cs_CZ.json index 9514c96394a..f352a8db458 100644 --- a/lib/l10n/cs_CZ.json +++ b/lib/l10n/cs_CZ.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "To lze obvykle vyřešit povolením zápisu webovému serveru do konfiguračního adresáře", "See %s" : "Viz %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "To lze obvykle vyřešit %spovolením zápisu webovému serveru do konfiguračního adresáře%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Soubory aplikace \"%$1s\" (%$2s) nebyly řádně nahrazeny.", "Sample configuration detected" : "Byla detekována vzorová konfigurace", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Pravděpodobně byla zkopírována konfigurační nastavení ze vzorových souborů. Toto není podporováno a může poškodit vaši instalaci. Nahlédněte prosím do dokumentace před prováděním změn v souboru config.php", "PHP %s or higher is required." : "Je vyžadováno PHP %s nebo vyšší.", diff --git a/lib/l10n/de.js b/lib/l10n/de.js index 28a4da2419e..8f6047acb47 100644 --- a/lib/l10n/de.js +++ b/lib/l10n/de.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Dies kann normalerweise repariert werden, indem dem Webserver Schreibzugriff auf das config-Verzeichnis gegeben wird", "See %s" : "Siehe %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dies kann normalerweise behoben werden, %sindem dem Webserver Schreibzugriff auf das Konfigurationsverzeichnis gegeben wird%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Die Dateien der App \"%$1s\" (%$2s) wurden nicht korrekt ersetzt.", "Sample configuration detected" : "Beispielkonfiguration gefunden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Es wurde festgestellt, dass die Beispielkonfiguration kopiert wurde. Dies kann Ihre Installation zunichte machen und wird nicht unterstützt. Bitte die Dokumentation lesen, bevor Änderungen an der config.php vorgenommen werden.", "PHP %s or higher is required." : "PHP %s oder höher wird benötigt.", diff --git a/lib/l10n/de.json b/lib/l10n/de.json index 163965e2689..30bbe1e9b3b 100644 --- a/lib/l10n/de.json +++ b/lib/l10n/de.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Dies kann normalerweise repariert werden, indem dem Webserver Schreibzugriff auf das config-Verzeichnis gegeben wird", "See %s" : "Siehe %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dies kann normalerweise behoben werden, %sindem dem Webserver Schreibzugriff auf das Konfigurationsverzeichnis gegeben wird%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Die Dateien der App \"%$1s\" (%$2s) wurden nicht korrekt ersetzt.", "Sample configuration detected" : "Beispielkonfiguration gefunden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Es wurde festgestellt, dass die Beispielkonfiguration kopiert wurde. Dies kann Ihre Installation zunichte machen und wird nicht unterstützt. Bitte die Dokumentation lesen, bevor Änderungen an der config.php vorgenommen werden.", "PHP %s or higher is required." : "PHP %s oder höher wird benötigt.", diff --git a/lib/l10n/de_DE.js b/lib/l10n/de_DE.js index a71b7cf72c6..1fd8fdc18ce 100644 --- a/lib/l10n/de_DE.js +++ b/lib/l10n/de_DE.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Dies kann normalerweise repariert werden, indem dem Webserver Schreibzugriff auf das config-Verzeichnis gegeben wird", "See %s" : "Siehe %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dies kann normalerweise behoben werden, %sindem dem Webserver Schreibzugriff auf das Konfigurationsverzeichnis gegeben wird%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Die Dateien der App \"%$1s\" (%$2s) wurden nicht korrekt ersetzt.", "Sample configuration detected" : "Beispielkonfiguration gefunden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Es wurde festgestellt, dass die Beispielkonfiguration kopiert wurde. Dies kann Ihre Installation zerstören und wird nicht unterstützt. Bitte lesen Sie die Dokumentation, bevor Sie Änderungen an der config.php vornehmen.", "PHP %s or higher is required." : "PHP %s oder höher wird benötigt.", diff --git a/lib/l10n/de_DE.json b/lib/l10n/de_DE.json index 8d2953651e5..7fa221231c2 100644 --- a/lib/l10n/de_DE.json +++ b/lib/l10n/de_DE.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Dies kann normalerweise repariert werden, indem dem Webserver Schreibzugriff auf das config-Verzeichnis gegeben wird", "See %s" : "Siehe %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dies kann normalerweise behoben werden, %sindem dem Webserver Schreibzugriff auf das Konfigurationsverzeichnis gegeben wird%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Die Dateien der App \"%$1s\" (%$2s) wurden nicht korrekt ersetzt.", "Sample configuration detected" : "Beispielkonfiguration gefunden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Es wurde festgestellt, dass die Beispielkonfiguration kopiert wurde. Dies kann Ihre Installation zerstören und wird nicht unterstützt. Bitte lesen Sie die Dokumentation, bevor Sie Änderungen an der config.php vornehmen.", "PHP %s or higher is required." : "PHP %s oder höher wird benötigt.", diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js index 83de61e7125..b1b76991b2b 100644 --- a/lib/l10n/fr.js +++ b/lib/l10n/fr.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Ce problème est généralement résolu en donnant au serveur web un accès en écriture au répertoire \"config\"", "See %s" : "Voir %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ce problème est généralement résolu %sen donnant au serveur web un accès en écriture au répertoire de configuration%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Les fichiers de l'application « %$1s » (%$2s) n'ont pas été remplacés correctement.", "Sample configuration detected" : "Configuration d'exemple détectée", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Il a été détecté que la configuration donnée à titre d'exemple a été copiée. Cela peut rendre votre installation inopérante et n'est pas pris en charge. Veuillez lire la documentation avant d'effectuer des modifications dans config.php", "PHP %s or higher is required." : "PHP %s ou supérieur est requis.", diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json index caebeab4741..89893d2209a 100644 --- a/lib/l10n/fr.json +++ b/lib/l10n/fr.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Ce problème est généralement résolu en donnant au serveur web un accès en écriture au répertoire \"config\"", "See %s" : "Voir %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ce problème est généralement résolu %sen donnant au serveur web un accès en écriture au répertoire de configuration%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Les fichiers de l'application « %$1s » (%$2s) n'ont pas été remplacés correctement.", "Sample configuration detected" : "Configuration d'exemple détectée", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Il a été détecté que la configuration donnée à titre d'exemple a été copiée. Cela peut rendre votre installation inopérante et n'est pas pris en charge. Veuillez lire la documentation avant d'effectuer des modifications dans config.php", "PHP %s or higher is required." : "PHP %s ou supérieur est requis.", diff --git a/lib/l10n/hu_HU.js b/lib/l10n/hu_HU.js index 92651f45303..f3d5a740ab4 100644 --- a/lib/l10n/hu_HU.js +++ b/lib/l10n/hu_HU.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Ez rendszerint úgy oldható meg, hogy írási jogot adunk a webszervernek a config könyvtárra.", "See %s" : "Lásd %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ez rendszerint úgy oldható meg, hogy %sírási jogot adunk a webszervernek a config könyvtárra%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "\"%$1s\" (%$2s) alkalmazás fájljai nem megfelelően lettek cserélve.", "Sample configuration detected" : "A példabeállítások vannak beállítva", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Úgy tűnik a példakonfigurációt próbálja ténylegesen használni. Ez nem támogatott, és működésképtelenné teheti a telepítést. Kérlek olvasd el a dokumentációt és azt követően változtas a config.php-n!", "PHP %s or higher is required." : "PHP %s vagy ennél újabb szükséges.", diff --git a/lib/l10n/hu_HU.json b/lib/l10n/hu_HU.json index ae980944269..29e4504a895 100644 --- a/lib/l10n/hu_HU.json +++ b/lib/l10n/hu_HU.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Ez rendszerint úgy oldható meg, hogy írási jogot adunk a webszervernek a config könyvtárra.", "See %s" : "Lásd %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ez rendszerint úgy oldható meg, hogy %sírási jogot adunk a webszervernek a config könyvtárra%s.", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "\"%$1s\" (%$2s) alkalmazás fájljai nem megfelelően lettek cserélve.", "Sample configuration detected" : "A példabeállítások vannak beállítva", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Úgy tűnik a példakonfigurációt próbálja ténylegesen használni. Ez nem támogatott, és működésképtelenné teheti a telepítést. Kérlek olvasd el a dokumentációt és azt követően változtas a config.php-n!", "PHP %s or higher is required." : "PHP %s vagy ennél újabb szükséges.", diff --git a/lib/l10n/it.js b/lib/l10n/it.js index af47d8f9e17..c61ac244637 100644 --- a/lib/l10n/it.js +++ b/lib/l10n/it.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Ciò può essere normalmente corretto fornendo al server web accesso in scrittura alla cartella \"config\"", "See %s" : "Vedi %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ciò può essere normalmente corretto %sfornendo al server web accesso in scrittura alla cartella \"config\"%s", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "I file dell'applicazione \"%1$s\" (%2$s) non sono stati sostituiti correttamente.", "Sample configuration detected" : "Configurazione di esempio rilevata", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "È stato rilevato che la configurazione di esempio è stata copiata. Ciò può compromettere la tua installazione e non è supportato. Leggi la documentazione prima di modificare il file config.php", "PHP %s or higher is required." : "Richiesto PHP %s o superiore", diff --git a/lib/l10n/it.json b/lib/l10n/it.json index cb4b4139b07..4e310444042 100644 --- a/lib/l10n/it.json +++ b/lib/l10n/it.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Ciò può essere normalmente corretto fornendo al server web accesso in scrittura alla cartella \"config\"", "See %s" : "Vedi %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Ciò può essere normalmente corretto %sfornendo al server web accesso in scrittura alla cartella \"config\"%s", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "I file dell'applicazione \"%1$s\" (%2$s) non sono stati sostituiti correttamente.", "Sample configuration detected" : "Configurazione di esempio rilevata", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "È stato rilevato che la configurazione di esempio è stata copiata. Ciò può compromettere la tua installazione e non è supportato. Leggi la documentazione prima di modificare il file config.php", "PHP %s or higher is required." : "Richiesto PHP %s o superiore", diff --git a/lib/l10n/nl.js b/lib/l10n/nl.js index ed9100bfaf8..f44511d8cb2 100644 --- a/lib/l10n/nl.js +++ b/lib/l10n/nl.js @@ -5,7 +5,6 @@ OC.L10N.register( "This can usually be fixed by giving the webserver write access to the config directory" : "Dit kan hersteld worden door de webserver schrijfrechten te geven op de de config directory", "See %s" : "Zie %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dit kan hersteld worden door de webserver %sschrijfrechten te geven op de de config directory%s", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Het bestand van de app \"%$1s\" (%$2s) zijn niet correct vervangen.", "Sample configuration detected" : "Voorbeeldconfiguratie gevonden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Blijkbaar is de voorbeeldconfiguratie gekopieerd. Dit kan je installatie beschadigen en wordt dan ook niet ondersteund. Lees de documentatie voordat je wijzigingen aan config.php doorvoert", "PHP %s or higher is required." : "PHP %s of hoger vereist.", diff --git a/lib/l10n/nl.json b/lib/l10n/nl.json index 53394c890ab..1cdd9430893 100644 --- a/lib/l10n/nl.json +++ b/lib/l10n/nl.json @@ -3,7 +3,6 @@ "This can usually be fixed by giving the webserver write access to the config directory" : "Dit kan hersteld worden door de webserver schrijfrechten te geven op de de config directory", "See %s" : "Zie %s", "This can usually be fixed by %sgiving the webserver write access to the config directory%s." : "Dit kan hersteld worden door de webserver %sschrijfrechten te geven op de de config directory%s", - "The files of the app \"%$1s\" (%$2s) were not replaced correctly." : "Het bestand van de app \"%$1s\" (%$2s) zijn niet correct vervangen.", "Sample configuration detected" : "Voorbeeldconfiguratie gevonden", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Blijkbaar is de voorbeeldconfiguratie gekopieerd. Dit kan je installatie beschadigen en wordt dan ook niet ondersteund. Lees de documentatie voordat je wijzigingen aan config.php doorvoert", "PHP %s or higher is required." : "PHP %s of hoger vereist.", diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 55fd575e129..fca5c9b87ac 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -31,6 +31,7 @@ namespace OC\App; +use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\App\ManagerEvent; use OCP\IAppConfig; @@ -266,6 +267,21 @@ class AppManager implements IAppManager { } /** + * Get the directory for the given app. + * + * @param string $appId + * @return string + * @throws AppPathNotFoundException if app folder can't be found + */ + public function getAppPath($appId) { + $appPath = \OC_App::getAppPath($appId); + if($appPath === false) { + throw new AppPathNotFoundException('Could not find path for ' . $appId); + } + return $appPath; + } + + /** * Clear the cached list of apps when enabling/disabling an app */ public function clearAppsCache() { diff --git a/lib/private/AppFramework/Http/Output.php b/lib/private/AppFramework/Http/Output.php index 85f0e6f8feb..1d77350b1a2 100644 --- a/lib/private/AppFramework/Http/Output.php +++ b/lib/private/AppFramework/Http/Output.php @@ -48,12 +48,17 @@ class Output implements IOutput { } /** - * @param string $path + * @param string|resource $path or file handle * * @return bool false if an error occurred */ public function setReadfile($path) { - return @readfile($path); + if (is_resource($path)) { + $output = fopen('php://output', 'w'); + return stream_copy_to_stream($path, $output) > 0; + } else { + return @readfile($path); + } } /** diff --git a/lib/private/DB/QueryBuilder/QuoteHelper.php b/lib/private/DB/QueryBuilder/QuoteHelper.php index 6d15cec5a05..041718bce5a 100644 --- a/lib/private/DB/QueryBuilder/QuoteHelper.php +++ b/lib/private/DB/QueryBuilder/QuoteHelper.php @@ -61,6 +61,11 @@ class QuoteHelper { throw new \InvalidArgumentException('Only strings, Literals and Parameters are allowed'); } + $string = str_replace(' AS ', ' as ', $string); + if (substr_count($string, ' as ')) { + return implode(' as ', array_map([$this, 'quoteColumnName'], explode(' as ', $string, 2))); + } + if (substr_count($string, '.')) { list($alias, $columnName) = explode('.', $string, 2); diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 5083b99b862..3a3f51488e6 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -142,26 +142,38 @@ class Cache implements ICache { } return $data; } else { - //fix types - $data['fileid'] = (int)$data['fileid']; - $data['parent'] = (int)$data['parent']; - $data['size'] = 0 + $data['size']; - $data['mtime'] = (int)$data['mtime']; - $data['storage_mtime'] = (int)$data['storage_mtime']; - $data['encryptedVersion'] = (int)$data['encrypted']; - $data['encrypted'] = (bool)$data['encrypted']; - $data['storage'] = $this->storageId; - $data['mimetype'] = $this->mimetypeLoader->getMimetypeById($data['mimetype']); - $data['mimepart'] = $this->mimetypeLoader->getMimetypeById($data['mimepart']); - if ($data['storage_mtime'] == 0) { - $data['storage_mtime'] = $data['mtime']; - } - $data['permissions'] = (int)$data['permissions']; - return new CacheEntry($data); + return self::cacheEntryFromData($data, $this->storageId, $this->mimetypeLoader); } } /** + * Create a CacheEntry from database row + * + * @param array $data + * @param string $storageId + * @param IMimeTypeLoader $mimetypeLoader + * @return CacheEntry + */ + public static function cacheEntryFromData($data, $storageId, IMimeTypeLoader $mimetypeLoader) { + //fix types + $data['fileid'] = (int)$data['fileid']; + $data['parent'] = (int)$data['parent']; + $data['size'] = 0 + $data['size']; + $data['mtime'] = (int)$data['mtime']; + $data['storage_mtime'] = (int)$data['storage_mtime']; + $data['encryptedVersion'] = (int)$data['encrypted']; + $data['encrypted'] = (bool)$data['encrypted']; + $data['storage'] = $storageId; + $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); + $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); + if ($data['storage_mtime'] == 0) { + $data['storage_mtime'] = $data['mtime']; + } + $data['permissions'] = (int)$data['permissions']; + return new CacheEntry($data); + } + + /** * get the metadata of all files stored in $folder * * @param string $folder diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 1196c6b0760..d8bdca6a3c4 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -27,6 +27,7 @@ namespace OC\Files\Cache\Wrapper; use OC\Files\Cache\Cache; +use OCP\Files\Cache\ICacheEntry; /** * Jail to a subdirectory of the wrapped cache @@ -73,7 +74,7 @@ class CacheJail extends CacheWrapper { } /** - * @param array $entry + * @param ICacheEntry|array $entry * @return array */ protected function formatCacheEntry($entry) { @@ -111,7 +112,7 @@ class CacheJail extends CacheWrapper { * @throws \RuntimeException */ public function insert($file, array $data) { - return $this->cache->insert($this->getSourcePath($file), $data); + return $this->getCache()->insert($this->getSourcePath($file), $data); } /** @@ -121,7 +122,7 @@ class CacheJail extends CacheWrapper { * @param array $data */ public function update($id, array $data) { - $this->cache->update($id, $data); + $this->getCache()->update($id, $data); } /** @@ -131,7 +132,7 @@ class CacheJail extends CacheWrapper { * @return int */ public function getId($file) { - return $this->cache->getId($this->getSourcePath($file)); + return $this->getCache()->getId($this->getSourcePath($file)); } /** @@ -144,7 +145,7 @@ class CacheJail extends CacheWrapper { if ($file === '') { return -1; } else { - return $this->cache->getParentId($this->getSourcePath($file)); + return $this->getCache()->getParentId($this->getSourcePath($file)); } } @@ -155,7 +156,7 @@ class CacheJail extends CacheWrapper { * @return bool */ public function inCache($file) { - return $this->cache->inCache($this->getSourcePath($file)); + return $this->getCache()->inCache($this->getSourcePath($file)); } /** @@ -164,7 +165,7 @@ class CacheJail extends CacheWrapper { * @param string $file */ public function remove($file) { - $this->cache->remove($this->getSourcePath($file)); + $this->getCache()->remove($this->getSourcePath($file)); } /** @@ -174,14 +175,14 @@ class CacheJail extends CacheWrapper { * @param string $target */ public function move($source, $target) { - $this->cache->move($this->getSourcePath($source), $this->getSourcePath($target)); + $this->getCache()->move($this->getSourcePath($source), $this->getSourcePath($target)); } /** * remove all entries for files that are stored on the storage from the cache */ public function clear() { - $this->cache->remove($this->root); + $this->getCache()->remove($this->root); } /** @@ -190,7 +191,7 @@ class CacheJail extends CacheWrapper { * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE */ public function getStatus($file) { - return $this->cache->getStatus($this->getSourcePath($file)); + return $this->getCache()->getStatus($this->getSourcePath($file)); } private function formatSearchResults($results) { @@ -206,7 +207,7 @@ class CacheJail extends CacheWrapper { * @return array an array of file data */ public function search($pattern) { - $results = $this->cache->search($pattern); + $results = $this->getCache()->search($pattern); return $this->formatSearchResults($results); } @@ -217,7 +218,7 @@ class CacheJail extends CacheWrapper { * @return array */ public function searchByMime($mimetype) { - $results = $this->cache->searchByMime($mimetype); + $results = $this->getCache()->searchByMime($mimetype); return $this->formatSearchResults($results); } @@ -229,7 +230,7 @@ class CacheJail extends CacheWrapper { * @return array */ public function searchByTag($tag, $userId) { - $results = $this->cache->searchByTag($tag, $userId); + $results = $this->getCache()->searchByTag($tag, $userId); return $this->formatSearchResults($results); } @@ -240,8 +241,8 @@ class CacheJail extends CacheWrapper { * @param array $data (optional) meta data of the folder */ public function correctFolderSize($path, $data = null) { - if ($this->cache instanceof Cache) { - $this->cache->correctFolderSize($this->getSourcePath($path), $data); + if ($this->getCache() instanceof Cache) { + $this->getCache()->correctFolderSize($this->getSourcePath($path), $data); } } @@ -253,8 +254,8 @@ class CacheJail extends CacheWrapper { * @return int */ public function calculateFolderSize($path, $entry = null) { - if ($this->cache instanceof Cache) { - return $this->cache->calculateFolderSize($this->getSourcePath($path), $entry); + if ($this->getCache() instanceof Cache) { + return $this->getCache()->calculateFolderSize($this->getSourcePath($path), $entry); } else { return 0; } @@ -292,7 +293,7 @@ class CacheJail extends CacheWrapper { * @return string|null */ public function getPathById($id) { - $path = $this->cache->getPathById($id); + $path = $this->getCache()->getPathById($id); return $this->getJailedPath($path); } @@ -309,6 +310,6 @@ class CacheJail extends CacheWrapper { if ($sourceCache === $this) { return $this->move($sourcePath, $targetPath); } - return $this->cache->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); + return $this->getCache()->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); } } diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 7a8177566c7..83fe7e5f43e 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -45,6 +45,10 @@ class CacheWrapper extends Cache { $this->cache = $cache; } + protected function getCache() { + return $this->cache; + } + /** * Make it easy for wrappers to modify every returned cache entry * @@ -62,7 +66,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry|false */ public function get($file) { - $result = $this->cache->get($file); + $result = $this->getCache()->get($file); if ($result) { $result = $this->formatCacheEntry($result); } @@ -76,7 +80,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry[] */ public function getFolderContents($folder) { - // can't do a simple $this->cache->.... call here since getFolderContentsById needs to be called on this + // can't do a simple $this->getCache()->.... call here since getFolderContentsById needs to be called on this // and not the wrapped cache $fileId = $this->getId($folder); return $this->getFolderContentsById($fileId); @@ -89,7 +93,7 @@ class CacheWrapper extends Cache { * @return array */ public function getFolderContentsById($fileId) { - $results = $this->cache->getFolderContentsById($fileId); + $results = $this->getCache()->getFolderContentsById($fileId); return array_map(array($this, 'formatCacheEntry'), $results); } @@ -121,7 +125,7 @@ class CacheWrapper extends Cache { * @throws \RuntimeException */ public function insert($file, array $data) { - return $this->cache->insert($file, $data); + return $this->getCache()->insert($file, $data); } /** @@ -131,7 +135,7 @@ class CacheWrapper extends Cache { * @param array $data */ public function update($id, array $data) { - $this->cache->update($id, $data); + $this->getCache()->update($id, $data); } /** @@ -141,7 +145,7 @@ class CacheWrapper extends Cache { * @return int */ public function getId($file) { - return $this->cache->getId($file); + return $this->getCache()->getId($file); } /** @@ -151,7 +155,7 @@ class CacheWrapper extends Cache { * @return int */ public function getParentId($file) { - return $this->cache->getParentId($file); + return $this->getCache()->getParentId($file); } /** @@ -161,7 +165,7 @@ class CacheWrapper extends Cache { * @return bool */ public function inCache($file) { - return $this->cache->inCache($file); + return $this->getCache()->inCache($file); } /** @@ -170,7 +174,7 @@ class CacheWrapper extends Cache { * @param string $file */ public function remove($file) { - $this->cache->remove($file); + $this->getCache()->remove($file); } /** @@ -180,18 +184,18 @@ class CacheWrapper extends Cache { * @param string $target */ public function move($source, $target) { - $this->cache->move($source, $target); + $this->getCache()->move($source, $target); } public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { - $this->cache->moveFromCache($sourceCache, $sourcePath, $targetPath); + $this->getCache()->moveFromCache($sourceCache, $sourcePath, $targetPath); } /** * remove all entries for files that are stored on the storage from the cache */ public function clear() { - $this->cache->clear(); + $this->getCache()->clear(); } /** @@ -200,7 +204,7 @@ class CacheWrapper extends Cache { * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE */ public function getStatus($file) { - return $this->cache->getStatus($file); + return $this->getCache()->getStatus($file); } /** @@ -210,7 +214,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry[] an array of file data */ public function search($pattern) { - $results = $this->cache->search($pattern); + $results = $this->getCache()->search($pattern); return array_map(array($this, 'formatCacheEntry'), $results); } @@ -221,7 +225,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry[] */ public function searchByMime($mimetype) { - $results = $this->cache->searchByMime($mimetype); + $results = $this->getCache()->searchByMime($mimetype); return array_map(array($this, 'formatCacheEntry'), $results); } @@ -233,7 +237,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry[] file data */ public function searchByTag($tag, $userId) { - $results = $this->cache->searchByTag($tag, $userId); + $results = $this->getCache()->searchByTag($tag, $userId); return array_map(array($this, 'formatCacheEntry'), $results); } @@ -244,8 +248,8 @@ class CacheWrapper extends Cache { * @param array $data (optional) meta data of the folder */ public function correctFolderSize($path, $data = null) { - if ($this->cache instanceof Cache) { - $this->cache->correctFolderSize($path, $data); + if ($this->getCache() instanceof Cache) { + $this->getCache()->correctFolderSize($path, $data); } } @@ -257,8 +261,8 @@ class CacheWrapper extends Cache { * @return int */ public function calculateFolderSize($path, $entry = null) { - if ($this->cache instanceof Cache) { - return $this->cache->calculateFolderSize($path, $entry); + if ($this->getCache() instanceof Cache) { + return $this->getCache()->calculateFolderSize($path, $entry); } else { return 0; } @@ -270,7 +274,7 @@ class CacheWrapper extends Cache { * @return int[] */ public function getAll() { - return $this->cache->getAll(); + return $this->getCache()->getAll(); } /** @@ -283,7 +287,7 @@ class CacheWrapper extends Cache { * @return string|bool the path of the folder or false when no folder matched */ public function getIncomplete() { - return $this->cache->getIncomplete(); + return $this->getCache()->getIncomplete(); } /** @@ -293,7 +297,7 @@ class CacheWrapper extends Cache { * @return string|null */ public function getPathById($id) { - return $this->cache->getPathById($id); + return $this->getCache()->getPathById($id); } /** @@ -302,7 +306,7 @@ class CacheWrapper extends Cache { * @return int */ public function getNumericStorageId() { - return $this->cache->getNumericStorageId(); + return $this->getCache()->getNumericStorageId(); } /** diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 14a32ba8f76..3ad2932e597 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -33,6 +33,7 @@ namespace OC\Files; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage\IStorage; +use OCP\Files\IHomeStorage; use OCP\IUser; class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { @@ -305,7 +306,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { } public function isMounted() { - $sid = $this->getStorage()->getId(); + $storage = $this->getStorage(); + if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { + return false; + } + $sid = $storage->getId(); if (!is_null($sid)) { $sid = explode(':', $sid); return ($sid[0] !== 'home' and $sid[0] !== 'shared'); diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index 87878562a42..440a8bc4608 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -51,7 +51,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider { * * @param IUser $user * @param IStorageFactory $loader - * @return \OCP\Files\Mount\IMountPoint[] + * @return \OCP\Files\Mount\IMountPoint */ public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { diff --git a/lib/private/Files/ObjectStore/S3.php b/lib/private/Files/ObjectStore/S3.php new file mode 100644 index 00000000000..5251b473bdf --- /dev/null +++ b/lib/private/Files/ObjectStore/S3.php @@ -0,0 +1,107 @@ +<?php +/** + * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Files\ObjectStore; + +use OCP\Files\ObjectStore\IObjectStore; + +// TODO: proper composer +set_include_path(get_include_path() . PATH_SEPARATOR . + \OC_App::getAppPath('files_external') . '/3rdparty/aws-sdk-php'); +require_once 'aws-autoloader.php'; + +class S3 implements IObjectStore { + use S3ConnectionTrait; + + public function __construct($parameters) { + $this->parseParams($parameters); + } + + /** + * @return string the container or bucket name where objects are stored + * @since 7.0.0 + */ + function getStorageId() { + return $this->id; + } + + /** + * @param string $urn the unified resource name used to identify the object + * @return resource stream with the read data + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function readObject($urn) { + // Create the command and serialize the request + $request = $this->getConnection()->getCommand('GetObject', [ + 'Bucket' => $this->bucket, + 'Key' => $urn + ])->prepare(); + + $request->dispatch('request.before_send', array( + 'request' => $request + )); + + $headers = $request->getHeaderLines(); + $headers[] = 'Connection: close'; + + $opts = [ + 'http' => [ + 'method' => "GET", + 'header' => $headers + ], + 'ssl' => [ + 'verify_peer' => true + ] + ]; + + $context = stream_context_create($opts); + return fopen($request->getUrl(), 'r', false, $context); + } + + /** + * @param string $urn the unified resource name used to identify the object + * @param resource $stream stream with the data to write + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function writeObject($urn, $stream) { + $this->getConnection()->putObject([ + 'Bucket' => $this->bucket, + 'Key' => $urn, + 'Body' => $stream + ]); + } + + /** + * @param string $urn the unified resource name used to identify the object + * @return void + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function deleteObject($urn) { + $this->getConnection()->deleteObject([ + 'Bucket' => $this->bucket, + 'Key' => $urn + ]); + } + +} diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php new file mode 100644 index 00000000000..a8b57cb18d3 --- /dev/null +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -0,0 +1,124 @@ +<?php +/** + * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Files\ObjectStore; + +use Aws\S3\Exception\S3Exception; +use Aws\S3\S3Client; + +trait S3ConnectionTrait { + /** @var array */ + protected $params; + + /** @var S3Client */ + protected $connection; + + /** @var string */ + protected $id; + + /** @var string */ + protected $bucket; + + /** @var int */ + protected $timeout; + + protected $test; + + protected function parseParams($params) { + if (empty($params['key']) || empty($params['secret']) || empty($params['bucket'])) { + throw new \Exception("Access Key, Secret and Bucket have to be configured."); + } + + $this->id = 'amazon::' . $params['bucket']; + + $this->test = isset($params['test']); + $this->bucket = $params['bucket']; + $this->timeout = (!isset($params['timeout'])) ? 15 : $params['timeout']; + $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region']; + $params['hostname'] = empty($params['hostname']) ? 's3.amazonaws.com' : $params['hostname']; + if (!isset($params['port']) || $params['port'] === '') { + $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; + } + $this->params = $params; + } + + + /** + * Returns the connection + * + * @return S3Client connected client + * @throws \Exception if connection could not be made + */ + protected function getConnection() { + if (!is_null($this->connection)) { + return $this->connection; + } + + $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https'; + $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/'; + + $options = [ + 'key' => $this->params['key'], + 'secret' => $this->params['secret'], + 'base_url' => $base_url, + 'region' => $this->params['region'], + S3Client::COMMAND_PARAMS => [ + 'PathStyle' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false, + ] + ]; + if (isset($this->params['proxy'])) { + $options[S3Client::REQUEST_OPTIONS] = ['proxy' => $this->params['proxy']]; + } + $this->connection = S3Client::factory($options); + + if (!$this->connection->isValidBucketName($this->bucket)) { + throw new \Exception("The configured bucket name is invalid."); + } + + if (!$this->connection->doesBucketExist($this->bucket)) { + try { + $this->connection->createBucket(array( + 'Bucket' => $this->bucket + )); + $this->connection->waitUntilBucketExists(array( + 'Bucket' => $this->bucket, + 'waiter.interval' => 1, + 'waiter.max_attempts' => 15 + )); + $this->testTimeout(); + } catch (S3Exception $e) { + \OCP\Util::logException('files_external', $e); + throw new \Exception('Creation of bucket failed. ' . $e->getMessage()); + } + } + + return $this->connection; + } + + /** + * when running the tests wait to let the buckets catch up + */ + private function testTimeout() { + if ($this->test) { + sleep($this->timeout); + } + } +} diff --git a/lib/private/Files/ObjectStore/StorageObjectStore.php b/lib/private/Files/ObjectStore/StorageObjectStore.php new file mode 100644 index 00000000000..044243c1ee6 --- /dev/null +++ b/lib/private/Files/ObjectStore/StorageObjectStore.php @@ -0,0 +1,90 @@ +<?php +/** + * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Files\ObjectStore; + +use OCP\Files\ObjectStore\IObjectStore; +use OCP\Files\Storage\IStorage; + +/** + * Object store that wraps a storage backend, mostly for testing purposes + */ +class StorageObjectStore implements IObjectStore { + /** @var IStorage */ + private $storage; + + /** + * @param IStorage $storage + */ + public function __construct(IStorage $storage) { + $this->storage = $storage; + } + + /** + * @return string the container or bucket name where objects are stored + * @since 7.0.0 + */ + function getStorageId() { + $this->storage->getId(); + } + + /** + * @param string $urn the unified resource name used to identify the object + * @return resource stream with the read data + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function readObject($urn) { + $handle = $this->storage->fopen($urn, 'r'); + if ($handle) { + return $handle; + } else { + throw new \Exception(); + } + } + + /** + * @param string $urn the unified resource name used to identify the object + * @param resource $stream stream with the data to write + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function writeObject($urn, $stream) { + $handle = $this->storage->fopen($urn, 'w'); + if ($handle) { + stream_copy_to_stream($stream, $handle); + fclose($handle); + } else { + throw new \Exception(); + } + } + + /** + * @param string $urn the unified resource name used to identify the object + * @return void + * @throws \Exception when something goes wrong, message will be logged + * @since 7.0.0 + */ + function deleteObject($urn) { + $this->storage->unlink($urn); + } + +} diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 3514c829691..7866f90157e 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -431,6 +431,7 @@ class View { echo fread($handle, $chunkSize); flush(); } + fclose($handle); $size = $this->filesize($path); return $size; } diff --git a/lib/private/Server.php b/lib/private/Server.php index c6755357a1d..c6cfa018be5 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -703,7 +703,8 @@ class Server extends ServerContainer implements IServerContainer { $c->getL10N('theming'), $c->getURLGenerator(), new \OC_Defaults(), - $c->getLazyRootFolder() + $c->getLazyRootFolder(), + $c->getMemCacheFactory() ); } return new \OC_Defaults(); diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index bdb6ac466ec..7a602950171 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -23,6 +23,8 @@ */ namespace OC\Share20; +use OC\Files\Cache\Cache; +use OC\Files\Cache\CacheEntry; use OCP\Files\File; use OCP\Files\Folder; use OCP\Share\IShareProvider; @@ -571,7 +573,7 @@ class DefaultShareProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - + $cursor = $qb->execute(); $data = $cursor->fetch(); $cursor->closeCursor(); @@ -656,7 +658,11 @@ class DefaultShareProvider implements IShareProvider { if ($shareType === \OCP\Share::SHARE_TYPE_USER) { //Get shares directly with this user $qb = $this->dbConn->getQueryBuilder(); - $qb->select('s.*', 'f.fileid', 'f.path') + $qb->select('s.*', + 'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash', + 'f.parent AS f_parent', 'f.name', 'f.mimetype', 'f.mimepart', 'f.size', 'f.mtime', 'f.storage_mtime', + 'f.encrypted', 'f.unencrypted_size', 'f.etag', 'f.checksum' + ) ->selectAlias('st.id', 'storage_string_id') ->from('share', 's') ->leftJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')) @@ -709,7 +715,11 @@ class DefaultShareProvider implements IShareProvider { } $qb = $this->dbConn->getQueryBuilder(); - $qb->select('s.*', 'f.fileid', 'f.path') + $qb->select('s.*', + 'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash', + 'f.parent AS f_parent', 'f.name', 'f.mimetype', 'f.mimepart', 'f.size', 'f.mtime', 'f.storage_mtime', + 'f.encrypted', 'f.unencrypted_size', 'f.etag', 'f.checksum' + ) ->selectAlias('st.id', 'storage_string_id') ->from('share', 's') ->leftJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')) @@ -798,7 +808,7 @@ class DefaultShareProvider implements IShareProvider { return $share; } - + /** * Create a share object from an database row * @@ -838,6 +848,15 @@ class DefaultShareProvider implements IShareProvider { $share->setExpirationDate($expiration); } + if (isset($data['f_permissions'])) { + $entryData = $data; + $entryData['permissions'] = $entryData['f_permissions']; + $entryData['parent'] = $entryData['f_parent'];; + $share->setNodeCacheEntry(Cache::cacheEntryFromData($entryData, + $entryData['storage_string_id'], + \OC::$server->getMimeTypeLoader())); + } + $share->setProviderId($this->identifier()); return $share; diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index e3e8482f4e1..2e7e6d0ca2e 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -22,6 +22,7 @@ */ namespace OC\Share20; +use OCP\Files\Cache\ICacheEntry; use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\Files\Node; @@ -72,6 +73,9 @@ class Share implements \OCP\Share\IShare { /** @var IUserManager */ private $userManager; + /** @var ICacheEntry|null */ + private $nodeCacheEntry; + public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { $this->rootFolder = $rootFolder; $this->userManager = $userManager; @@ -418,4 +422,18 @@ class Share implements \OCP\Share\IShare { public function getMailSend() { return $this->mailSend; } + + /** + * @inheritdoc + */ + public function setNodeCacheEntry(ICacheEntry $entry) { + $this->nodeCacheEntry = $entry; + } + + /** + * @inheritdoc + */ + public function getNodeCacheEntry() { + return $this->nodeCacheEntry; + } } diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 93517dc9f7e..bdf7bdafae3 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -157,7 +157,15 @@ class URLGenerator implements IURLGenerator { // Check if the app is in the app folder $path = ''; - if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { + if(\OCP\App::isEnabled('theming') && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); + if($app==="") { $app = "core"; } + $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; + } elseif(\OCP\App::isEnabled('theming') && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); + if($app==="") { $app = "core"; } + $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; + } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { diff --git a/lib/public/App/AppPathNotFoundException.php b/lib/public/App/AppPathNotFoundException.php new file mode 100644 index 00000000000..071eb2f8377 --- /dev/null +++ b/lib/public/App/AppPathNotFoundException.php @@ -0,0 +1,31 @@ +<?php +/** + * @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCP\App; + +/** + * Class AppPathNotFoundException + * + * @package OCP\App + * @since 11.0.0 + */ +class AppPathNotFoundException extends \Exception {}
\ No newline at end of file diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 44990b7c47c..057a964ce0a 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -79,6 +79,16 @@ interface IAppManager { public function disableApp($appId); /** + * Get the directory for the given app. + * + * @param string $appId + * @return string + * @since 11.0.0 + * @throws AppPathNotFoundException + */ + public function getAppPath($appId); + + /** * List all apps enabled for a user * * @param \OCP\IUser $user diff --git a/lib/public/AppFramework/Http/IOutput.php b/lib/public/AppFramework/Http/IOutput.php index 1544c7d6375..642bcf4170f 100644 --- a/lib/public/AppFramework/Http/IOutput.php +++ b/lib/public/AppFramework/Http/IOutput.php @@ -39,7 +39,7 @@ interface IOutput { public function setOutput($out); /** - * @param string $path + * @param string|resource $path or file handle * * @return bool false if an error occurred * @since 8.1.0 diff --git a/lib/public/AppFramework/Http/StreamResponse.php b/lib/public/AppFramework/Http/StreamResponse.php index b5852fb5620..e124bb4ccbf 100644 --- a/lib/public/AppFramework/Http/StreamResponse.php +++ b/lib/public/AppFramework/Http/StreamResponse.php @@ -37,7 +37,7 @@ class StreamResponse extends Response implements ICallbackResponse { private $filePath; /** - * @param string $filePath the path to the file which should be streamed + * @param string|resource $filePath the path to the file or a file handle which should be streamed * @since 8.1.0 */ public function __construct ($filePath) { @@ -54,7 +54,7 @@ class StreamResponse extends Response implements ICallbackResponse { public function callback (IOutput $output) { // handle caching if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { - if (!file_exists($this->filePath)) { + if (!(file_exists($this->filePath) || is_resource($this->filePath))) { $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); } elseif ($output->setReadfile($this->filePath) === false) { $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index 206b0e286a2..5b552b51c3c 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -22,6 +22,7 @@ namespace OCP\Share; +use OCP\Files\Cache\ICacheEntry; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\Node; @@ -324,4 +325,20 @@ interface IShare { * @since 9.0.0 */ public function getMailSend(); + + /** + * Set the cache entry for the shared node + * + * @param ICacheEntry $entry + * @since 11.0.0 + */ + public function setNodeCacheEntry(ICacheEntry $entry); + + /** + * Get the cache entry for the shared node + * + * @return null|ICacheEntry + * @since 11.0.0 + */ + public function getNodeCacheEntry(); } |