Skip to content

Commit

Permalink
nortmalize path before adding it to the fscache to avoid multiple fsc…
Browse files Browse the repository at this point in the history
…ache entries for the same file
  • Loading branch information
Björn Schießle committed Oct 12, 2012
1 parent b761143 commit d7f4394
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/filecache.php
Expand Up @@ -62,6 +62,9 @@ public static function get($path,$root=false) {
* $data is an assiciative array in the same format as returned by get
*/
public static function put($path,$data,$root=false) {
if ($path != '') {
$path = OC_Filesystem::normalizePath($path);
}
if($root===false) {
$root=OC_Filesystem::getRoot();
}
Expand Down

2 comments on commit d7f4394

@icewind1991
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is necessary? paths are already normalized by the filesystem layer before being passed to the cache (and other hooks)

@schiessle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases it seems to bypass the normalizing step in the filesystem layer, e.g. if certain actions get triggered through webdav.

One example where this happens:

  • Mount a ownCloud into another ownCloud. After the external ownCloud was mounted you have duplicated entries in the fscache once with one leading '/' and once with two.

I still investigate why this fscache update happens at all. But until we know more this fix will help to prevent duplicates in the database.

Beside that I think it is not a bad idea to have the normalizing step as low as possible in the code stack. This reduces the chance that it gets bypassed.

Please sign in to comment.