From d5c73c6d4ab525d54d4a490a30fc6e86cf9a38b5 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind1991@gmail.com>
Date: Fri, 26 Aug 2011 15:17:39 +0200
Subject: [PATCH] always scan new music files

---
 apps/media/lib_media.php | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php
index 062672b91e..3086f84a93 100644
--- a/apps/media/lib_media.php
+++ b/apps/media/lib_media.php
@@ -24,10 +24,8 @@
 //we need to have the sha256 hash of passwords for ampache
 OC_Hook::connect('OC_User','post_login','OC_MEDIA','loginListener');
 
-//connect to the filesystem for auto updating if configured
-if(OC_Preferences::getValue(OC_User::getUser(),'media','autoupdate',false)){
-	OC_Hook::connect('OC_Filesystem','post_write','OC_MEDIA','updateFile');
-}
+//connect to the filesystem for auto updating
+OC_Hook::connect('OC_Filesystem','post_write','OC_MEDIA','updateFile');
 
 //listen for file deletions to clean the database if a song is deleted
 OC_Hook::connect('OC_Filesystem','delete','OC_MEDIA','deleteFile');
@@ -56,20 +54,14 @@ class OC_MEDIA{
 	 */
 	public static function updateFile($params){
 		$path=$params['path'];
-		$folderNames=explode(PATH_SEPARATOR,OC_Preferences::getValue(OC_User::getUser(),'media','paths',''));
-		foreach($folderNames as $folder){
-			if(substr($path,0,strlen($folder))==$folder){
-				require_once 'lib_scanner.php';
-				require_once 'lib_collection.php';
-				//fix a bug where there were multiply '/' in front of the path, it should only be one
-				while($path[0]=='/'){
-					$path=substr($path,1);
-				}
-				$path='/'.$path;
-				error_log($path);
-				OC_MEDIA_SCANNER::scanFile($path);
-			}
+		require_once 'lib_scanner.php';
+		require_once 'lib_collection.php';
+		//fix a bug where there were multiply '/' in front of the path, it should only be one
+		while($path[0]=='/'){
+			$path=substr($path,1);
 		}
+		$path='/'.$path;
+		OC_MEDIA_SCANNER::scanFile($path);
 	}
 
 	/**
-- 
GitLab