Fix delete swap if swap doesnt exist

This commit is contained in:
Lucas Noki 2020-01-21 23:58:34 +01:00
parent dd03126057
commit 2c944fe209

View File

@ -43,7 +43,8 @@ class SwapModule(AbstractModule):
print("Swap is located here:", final_list[5])
self.swap_file = final_list[5]
except IndexError:
print("Swap file doesn´t exist!\n")
print("Swap file doesn´t exist!")
return "None"
def get_swap_size(self):
swap_size = subprocess.check_output(['swapon', '--show']).decode("UTF-8")
@ -116,7 +117,10 @@ class SwapModule(AbstractModule):
print("Temporary swapiness is " + str(actions[selected_swapiness]))
def delete_swap(self):
self.swap_location_check()
location = self.swap_location_check()
if location == "None":
return None
else:
disable_swapfile = "sudo swapoff {} && ".format(self.swap_file) + \
"sudo rm {}".format(self.swap_file)