From c0a498de02cebaa9bd462d611599f0be6809357e Mon Sep 17 00:00:00 2001
From: Ludovic Pouzenc <lpouzenc@gmail.com>
Date: Sun, 12 Jul 2015 00:32:39 +0200
Subject: Bugfix : /config/tasks_find_files_pathlist could have multiple paths
 now

---
 mytasks.py     |  3 +++
 raidguessfs.py | 22 ++++++----------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/mytasks.py b/mytasks.py
index 3e4056f..235a1be 100644
--- a/mytasks.py
+++ b/mytasks.py
@@ -113,6 +113,9 @@ class MyTasks():
         else:
             raise ValueError('Valid task names are : %s'%','.join(MyTasks.TASK_NAMES))
 
+    def append_find_files_pathlist(self, path):
+        self.find_files_pathlist.append(path)
+
     def set_find_files_pathlist(self, new_find_files_pathlist):
         self.find_files_pathlist = new_find_files_pathlist
 
diff --git a/raidguessfs.py b/raidguessfs.py
index 94f36e7..84440c9 100755
--- a/raidguessfs.py
+++ b/raidguessfs.py
@@ -81,7 +81,7 @@ class RaidGuessFS(fuse.Fuse):
                 self.update_raid_start, self.update_raid_end, self.update_raid_chunk_size, self.update_raid_disk_order,
                 self.raid.set_raid_layout,
                 self.update_bmp_height, self.update_bmp_width, self.update_bmp_start_offset,
-                self.tasks.task_start, self.tasks.task_kill, self.update_task_find_files_pathlist,
+                self.tasks.task_start, self.tasks.task_kill, self.tasks.append_find_files_pathlist
                 ]
 
 
@@ -203,19 +203,6 @@ class RaidGuessFS(fuse.Fuse):
         self._refresh_raid_fattr()
         logging.debug("Exit. update_raid_disk_order(%s)"%arg)
 
-    def update_task_find_files_pathlist(self, arg):
-        logging.debug("Enter update_task_find_files_pathlist(%s)"%arg)
-        if type(arg) is str:
-            l = arg.split()
-        elif type(arg) is list:
-            l = arg
-        else:
-            raise TypeError('update_task_find_files_pathlist() wants a list or str')
-
-        # FIXME : write() is usually called after each end line, so the previous path are destroyed
-        self.tasks.set_find_files_pathlist(l)
-        logging.debug("Exit. update_task_find_files_pathlist(%s)"%arg)
-
     def get_task_start(self):
         return 'Write a task_name in this pseudo-file to start it\n'
     
@@ -278,8 +265,11 @@ class RaidGuessFS(fuse.Fuse):
 
     def truncate(self, path, size):
         logging.info("truncate: %s (size %s)" % (path, size))
-        if path.startswith('/config/'):
-            return # Ignore truncates on pseudo config files
+        
+        if path == '/config/task_find_files_pathlist':
+            self.tasks.set_find_files_pathlist([])
+        elif path.startswith('/config/'):
+            return # Ignore truncates on others pseudo config files
         else:
             return -errno.EOPNOTSUPP
 
-- 
cgit v1.2.3