From 48dabd2c145be296b575fe1ff47b800fc31e06ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= <schiessle@owncloud.com>
Date: Tue, 9 Apr 2013 15:27:19 +0200
Subject: [PATCH] size of the trash bin could be incorrect, remove it for all
 users to enforce a recalculation during next usage.

---
 apps/files_trashbin/appinfo/update.php | 40 ++++----------------------
 apps/files_trashbin/appinfo/version    |  2 +-
 2 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/apps/files_trashbin/appinfo/update.php b/apps/files_trashbin/appinfo/update.php
index b0bf79cc51..f4dad7b26b 100644
--- a/apps/files_trashbin/appinfo/update.php
+++ b/apps/files_trashbin/appinfo/update.php
@@ -1,40 +1,10 @@
 <?php
 
 $installedVersion=OCP\Config::getAppValue('files_trashbin', 'installed_version');
-// move versions to new directory
 
-if (version_compare($installedVersion, '0.2', '<')) {
-	$datadir = \OCP\Config::getSystemValue('datadirectory').'/';
-
-	$users = \OCP\User::getUsers();
-	foreach ($users as $user) {
-		
-		//create new folders
-		@mkdir($datadir.$user.'/files_trashbin/files');
-		@mkdir($datadir.$user.'/files_trashbin/versions');
-		@mkdir($datadir.$user.'/files_trashbin/keyfiles');
-			
-		// move files to the new folders
-		if ($handle = opendir($datadir.$user.'/files_trashbin')) {
-			while (false !== ($file = readdir($handle))) {
-				if ($file != "." && $file != ".." && $file != 'files' && $file != 'versions' && $file != 'keyfiles') {
-					rename($datadir.$user.'/files_trashbin/'.$file,
-							$datadir.$user.'/files_trashbin/files/'.$file);
-				}
-			}
-			closedir($handle);
-		}
-				
-		// move versions to the new folder
-		if ($handle = opendir($datadir.$user.'/versions_trashbin')) {
-			while (false !== ($file = readdir($handle))) {
-				rename($datadir.$user.'/versions_trashbin/'.$file,
-						$datadir.$user.'/files_trashbin/versions/'.$file);
-			}
-			closedir($handle);
-		}
-		
-		@rmdir($datadir.$user.'/versions_trashbin');
-		
-	}
+if (version_compare($installedVersion, '0.4', '<')) {
+	//size of the trash bin could be incorrect, remove it for all users to
+	//enforce a recalculation during next usage.
+	$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trashsize`');
+	$result = $query->execute();
 }
\ No newline at end of file
diff --git a/apps/files_trashbin/appinfo/version b/apps/files_trashbin/appinfo/version
index be58634173..bd73f47072 100644
--- a/apps/files_trashbin/appinfo/version
+++ b/apps/files_trashbin/appinfo/version
@@ -1 +1 @@
-0.3
+0.4
-- 
GitLab