From 374e3475c9e2e0220cc8639a1a06f68b7f43fb2b Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Tue, 21 Jan 2014 23:58:48 +0100
Subject: Also remove the user's home storage from the storage table when
 deleting a user

---
 lib/private/files/cache/storage.php | 13 +++++++++++++
 lib/private/user.php                |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/lib/private/files/cache/storage.php b/lib/private/files/cache/storage.php
index 5657cf06e12..6d7a1002c1b 100644
--- a/lib/private/files/cache/storage.php
+++ b/lib/private/files/cache/storage.php
@@ -70,4 +70,17 @@ class Storage {
 			return false;
 		}
 	}
+
+	/**
+	 * remove the entry for the storage
+	 *
+	 * @param string $storageId
+	 */
+	public static function remove($storageId) {
+		if (strlen($storageId) > 64) {
+			$storageId = md5($storageId);
+		}
+		$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
+		\OC_DB::executeAudited($sql, array($storageId));
+	}
 }
diff --git a/lib/private/user.php b/lib/private/user.php
index 98ebebbe5c1..2519200d0f0 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -205,6 +205,9 @@ class OC_User {
 				// Delete user files in /data/
 				OC_Helper::rmdirr(\OC_User::getHome($uid));
 
+				// Delete the users entry in the storage table
+				\OC\Files\Cache\Storage::remove('home::' . $uid);
+
 				// Remove it from the Cache
 				self::getManager()->delete($uid);
 			}
-- 
cgit v1.2.3