From 65eee1f69dbbbe86bb4bf0716a464dc9f2c66a67 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Fri, 30 Mar 2012 19:44:38 +0200
Subject: [PATCH] clean pre-path_hash fscache entries

---
 db_structure.xml    | 3 +--
 files/ajax/scan.php | 1 +
 lib/filecache.php   | 8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/db_structure.xml b/db_structure.xml
index 82d2a731d4c..2df218d359c 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -67,8 +67,7 @@
    <field>
 	   <name>path_hash</name>
 	   <type>text</type>
-	   <default>
-	   </default>
+	   <default></default>
 	   <notnull>true</notnull>
 	   <length>32</length>
    </field>
diff --git a/files/ajax/scan.php b/files/ajax/scan.php
index 565275911b4..db09b7d5c64 100644
--- a/files/ajax/scan.php
+++ b/files/ajax/scan.php
@@ -17,6 +17,7 @@ if($force or !OC_FileCache::inCache('')){
 	if(!$checkOnly){
 		OC_DB::beginTransaction();
 		OC_FileCache::scan('',$eventSource);
+		OC_FileCache::clean();
 		OC_DB::commit();
 		$eventSource->send('success',true);
 	}else{
diff --git a/lib/filecache.php b/lib/filecache.php
index a8c48e3f144..86d865ed9f3 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -637,6 +637,14 @@ class OC_FileCache{
 			self::fileSystemWatcherWrite(array('path'=>$path),$root);
 		}
 	}
+
+	/**
+	 * clean old pre-path_hash entries
+	 */
+	public static function clean(){
+		$query=OC_DB::prepare('DELETE FROM *PREFIX*fscache WHERE LENGTH(path_hash)<30');
+		$query->execute();
+	}
 }
 
 //watch for changes and try to keep the cache up to date
-- 
GitLab