mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-07 08:02:04 +01:00
Refactor FileManager: Update file paths for hello.txt and enhance directory mutability settings. Allow specific directories to remain mutable by adjusting chattr settings for logs, trash, backup, incbackup, lscache, and .cagefs.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user