删除软件包发布记录时同时删除对应的包文件夹和tar文件
This commit is contained in:
parent
d2ae85c996
commit
05ff9b27d1
@ -2,6 +2,7 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@ -136,3 +137,22 @@ class PackageRelease(Page):
|
|||||||
|
|
||||||
file.flags.ignore_duplicate_entry_error = True
|
file.flags.ignore_duplicate_entry_error = True
|
||||||
file.insert()
|
file.insert()
|
||||||
|
|
||||||
|
def after_delete(self):
|
||||||
|
"""Clean up related files after Package Release deletion"""
|
||||||
|
if self.package:
|
||||||
|
try:
|
||||||
|
package = jingrow.get_pg("Package", self.package)
|
||||||
|
if package:
|
||||||
|
# Delete package directory
|
||||||
|
package_dir = Path(jingrow.get_site_path("packages", package.package_name))
|
||||||
|
if package_dir.exists():
|
||||||
|
shutil.rmtree(package_dir)
|
||||||
|
|
||||||
|
# Delete tar file
|
||||||
|
if self.path:
|
||||||
|
tar_file = Path(jingrow.get_site_path("public", self.path.lstrip("/")))
|
||||||
|
if tar_file.exists():
|
||||||
|
tar_file.unlink()
|
||||||
|
except Exception as e:
|
||||||
|
jingrow.log_error("Package Release cleanup error", str(e))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user