{"action":"opened","issue":{"url":"https://api.github.com/repos/owncloud/core/issues/13507","labels_url":"https://api.github.com/repos/owncloud/core/issues/13507/labels{/name}","comments_url":"https://api.github.com/repos/owncloud/core/issues/13507/comments","events_url":"https://api.github.com/repos/owncloud/core/issues/13507/events","html_url":"https://github.com/owncloud/core/issues/13507","id":54874334,"number":13507,"title":"Amazon S3 external folders not being registered","user":{"login":"alappo","id":6057724,"avatar_url":"https://avatars.githubusercontent.com/u/6057724?v=3","gravatar_id":"","url":"https://api.github.com/users/alappo","html_url":"https://github.com/alappo","followers_url":"https://api.github.com/users/alappo/followers","following_url":"https://api.github.com/users/alappo/following{/other_user}","gists_url":"https://api.github.com/users/alappo/gists{/gist_id}","starred_url":"https://api.github.com/users/alappo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alappo/subscriptions","organizations_url":"https://api.github.com/users/alappo/orgs","repos_url":"https://api.github.com/users/alappo/repos","events_url":"https://api.github.com/users/alappo/events{/privacy}","received_events_url":"https://api.github.com/users/alappo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-20T11:52:58Z","updated_at":"2015-01-20T11:52:58Z","closed_at":null,"body":"### Steps to reproduce\r\n1. Create external storage link to S3 bucket\r\n2. Upload files directly into S3, a couple of directories deep, so that Owncloud has no idea of these 'nested' files\r\n3. Run the files:scan tool on the command line\r\n4. Notice that the immediate sub directories of the bucket are picked up by the scan (they appear in the output), but this does not recursively pass through these folders, searching for more folders within the directory\r\n\r\n### Expected behaviour\r\nI understand that amazon has no concept of folders as such, but Owncloud should notice (considering it sends a request to S3 at this point) that there could be folders here, and search within these folders for more folders. It will pick up immediate files, but doesn't register any folders.\r\n\r\n### Actual behaviour\r\nThe scan tool notices the bucket root folder, and ends the check there, as the file_exists method call (later on in the process), which calls out to filetype($path) fails the check. The bug appears to be down to the use of the following code in apps/files_external/lib/amazons3.php:\r\n\r\n```php\r\nif ($this->getConnection()->doesObjectExist($this->bucket, $path.'/')) {\r\n    return 'dir';\r\n}\r\n```\r\n\r\nIt looks to me like it will never return true here. From looking at the doesObjectExist method in the AWS SDK, this only works with full object paths, and not a 'directory' key, regardless of whether a slash is added to the end.\r\n\r\nSomething along the lines of:\r\n\r\n```php\r\n$objectList = $this->getConnection()->listObjects(array('Bucket' => $this->bucket, \"Prefix\" => $path, \"MaxKeys\" => 1));\r\nif (!empty($objectList[\"Contents\"])) {\r\n    return 'dir';\r\n}\r\n```\r\n\r\nwhich checks the path for objects, results in the expected behaviour.\r\n\r\n### Server configuration\r\n**Operating system**:\r\nUbuntu 14.04\r\n\r\n**Web server:**\r\nApache2\r\n\r\n**Database:**\r\nMySql\r\n\r\n**PHP version:**\r\n5.6.4\r\n\r\n**ownCloud version:** (see ownCloud admin page)\r\n7.0.4 (stable)\r\n\r\n**Updated from an older ownCloud or fresh install:**\r\nFresh Install\r\n\r\n**List of activated apps:**\r\nFiles, Activity, Documents, Pictures, Calendar, Contacts\r\n\r\n**The content of config/config.php:**\r\n\r\n```php\r\n<?php\r\n$CONFIG = array (\r\n  'instanceid' => 'oc3ba9149512',\r\n  'passwordsalt' => '##############################',\r\n  'secret' => '##############################',\r\n  'trusted_domains' =>\r\n      array (\r\n        0 => '[IP ADDRESS]',\r\n      ),\r\n  'datadirectory' => '/var/www/owncloud/data',\r\n  'overwrite.cli.url' => 'http://[IP ADDRESS]',\r\n  'dbtype' => 'mysql',\r\n  'version' => '7.0.4.2',\r\n  'dbname' => 'DB_NAME',\r\n  'dbhost' => 'DB_HOST',\r\n  'dbtableprefix' => 'oc_',\r\n  'dbuser' => 'owncloud',\r\n  'dbpassword' => 'DB_PASSWORD',\r\n  'installed' => true,\r\n  'loglevel' => '0',\r\n);\r\n```\r\n\r\n**Are you using external storage, if yes which one:** local/smb/sftp/...\r\nAmazon S3\r\n\r\n**Are you using encryption:** yes/no\r\nNo\r\n\r\n### Client configuration\r\n**Browser:**\r\nFirefox 35.0\r\n\r\n**Operating system:**\r\nWindows 7 Professional\r\n\r\n### Logs\r\n#### ownCloud log (data/owncloud.log)\r\n```\r\nDebug \tOC\\Files\\Cache\\Scanner \t!!! Path '[PATH TO FOLDER WITHIN ACCESSIBLE FOLDER]' is not readable !!! \t2015-01-20T11:47:52+00:00 \r\n```\r\n"}}