Commit d10d8d4d authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Fixes in the file manager API, including creating the base path user directory if not existent.

parent a9a655a8
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -516,7 +516,10 @@ class FileManagerAPI(PrivateGETAPI, PrivatePOSTAPI):
            
            
            # Did we just get a "cannot stat - No such file or directory error?
            # Did we just get a "cannot stat - No such file or directory error?
            if 'No such file or directory' in out.stderr:
            if 'No such file or directory' in out.stderr:
                pass
                if path == '/':
                    self.mkdir(self.sanitize_and_prepare_shell_path('/', storage, user), user, storage, force=True)
                else:
                    return data
            else:
            else:
                raise Exception(out.stderr)
                raise Exception(out.stderr)
                            
                            
@@ -630,11 +633,14 @@ class FileManagerAPI(PrivateGETAPI, PrivatePOSTAPI):
        return out.stdout
        return out.stdout




    def mkdir(self, path, user, storage):
    def mkdir(self, path, user, storage, force=False):
        
        
        path = self.sanitize_and_prepare_shell_path(path, storage, user)
        path = self.sanitize_and_prepare_shell_path(path, storage, user)
        
        
        # Prepare command
        # Prepare command
        if force:
            command = self.ssh_command('mkdir -p {}'.format(path), user, storage.computing)
        else:
            command = self.ssh_command('mkdir {}'.format(path), user, storage.computing)
            command = self.ssh_command('mkdir {}'.format(path), user, storage.computing)
        
        
        # Execute_command
        # Execute_command