diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index ab7541a9f..9c89c2fb2 100644 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -211,7 +211,7 @@ class FileManager: currentFile = items.split(' ') currentFile = [a for a in currentFile if a != ''] - if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total' or currentFile[-1].startswith('mail.'): + if currentFile[-1] == '.' or currentFile[-1] == '..' or currentFile[0] == 'total': continue if len(currentFile) > 9: @@ -386,17 +386,17 @@ class FileManager: RemoveOK = 1 - command = 'touch %s/hello.txt' % (self.homePath) + command = 'touch %s/public_html/hello.txt' % (self.homePath) result = ProcessUtilities.outputExecutioner(command) - if result.find('No such file or directory') > -1: + if result.find('cannot touch') > -1: RemoveOK = 0 command = 'chattr -R -i %s' % (self.homePath) ProcessUtilities.executioner(command) else: - command = 'rm -f %s/hello.txt' % (self.homePath) + command = 'rm -f %s/public_html/hello.txt' % (self.homePath) ProcessUtilities.executioner(command) @@ -424,6 +424,25 @@ class FileManager: if RemoveOK == 0: command = 'chattr -R +i %s' % (self.homePath) ProcessUtilities.executioner(command) + + # Allow specific directories to remain mutable + command = 'chattr -R -i %s' % (self.homePath) + '/logs/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/.trash/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/backup/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/incbackup/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/lscache/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/.cagefs/' + ProcessUtilities.executioner(command) except: try: skipTrash = self.data['skipTrash'] @@ -435,17 +454,17 @@ class FileManager: RemoveOK = 1 - command = 'touch %s/hello.txt' % (self.homePath) + command = 'touch %s/public_html/hello.txt' % (self.homePath) result = ProcessUtilities.outputExecutioner(command) - if result.find('No such file or directory') > -1: + if result.find('cannot touch') > -1: RemoveOK = 0 command = 'chattr -R -i %s' % (self.homePath) ProcessUtilities.executioner(command) else: - command = 'rm -f %s/hello.txt' % (self.homePath) + command = 'rm -f %s/public_html/hello.txt' % (self.homePath) ProcessUtilities.executioner(command) for item in self.data['fileAndFolders']: @@ -462,6 +481,25 @@ class FileManager: if RemoveOK == 0: command = 'chattr -R +i %s' % (self.homePath) ProcessUtilities.executioner(command) + + # Allow specific directories to remain mutable + command = 'chattr -R -i %s' % (self.homePath) + '/logs/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/.trash/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/backup/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/incbackup/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/lscache/' + ProcessUtilities.executioner(command) + + command = 'chattr -R -i %s' % (self.homePath) + '/.cagefs/' + ProcessUtilities.executioner(command) json_data = json.dumps(finalData) return HttpResponse(json_data)