fixed delete method and build package

This commit is contained in:
hansrachit123 2025-09-16 14:59:08 -03:00
parent f753d47100
commit 7eca152e0c
8 changed files with 107 additions and 35 deletions

View File

@ -1,3 +1,3 @@
## Cockpit Navigator 0.5.11-3 ## Cockpit Navigator 0.5.11-4
* build package + fixed deletion method of tmp files * build package

View File

@ -4,7 +4,7 @@
"title": "Cockpit Navigator", "title": "Cockpit Navigator",
"description": "A File System Browser for Cockpit.", "description": "A File System Browser for Cockpit.",
"version": "0.5.11", "version": "0.5.11",
"build_number": "3", "build_number": "4",
"stable": false, "stable": false,
"author": "Josh Boudreau <jboudreau@45drives.com>", "author": "Josh Boudreau <jboudreau@45drives.com>",
"git_url": "https://github.com/45Drives/cockpit-navigator", "git_url": "https://github.com/45Drives/cockpit-navigator",
@ -32,8 +32,7 @@
"rsync", "rsync",
"zip", "zip",
"file", "file",
"/bin/mkdir", "coreutils",
"/bin/rmdir",
"inotify-tools" "inotify-tools"
] ]
}, },
@ -71,7 +70,7 @@
"changelog": { "changelog": {
"urgency": "medium", "urgency": "medium",
"version": "0.5.11", "version": "0.5.11",
"build_number": "3", "build_number": "4",
"date": null, "date": null,
"packager": "Josh Boudreau <jboudreau@45drives.com>", "packager": "Josh Boudreau <jboudreau@45drives.com>",
"changes": [] "changes": []

View File

@ -159,18 +159,73 @@ export class NavContextMenu {
} }
} }
if (result?.["archive-path"]) { if (result?.["archive-path"]) {
const unitName = `nav-clean-on-open-${Date.now()}-${Math.random().toString(36).slice(2,8)}`; const unitName = `nav-clean-sweep-on-close-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;
const script = [
'set -euo pipefail', const script = `
'if ! command -v inotifywait >/dev/null 2>&1; then ' + set -euo pipefail
'sleep 300; rm -f -- "$ARCHIVE"; ' +
'[ -n "${TEMPDIR:-}" ] && [[ "$TEMPDIR" == /tmp/navigator-* ]] && rm -rf -- "$TEMPDIR"; ' + ARCHIVE="$ARCHIVE"
'exit 0; fi', DIR="$(dirname -- "$ARCHIVE")"
'inotifywait -q -t 1800 -e open -- "$ARCHIVE" || true', BASE="$(basename -- "$ARCHIVE")"
'rm -f -- "$ARCHIVE"', ROOT="/tmp/navigator"
'sleep 3600', PATTERN="navigator-download*"
'[ -n "${TEMPDIR:-}" ] && [[ "$TEMPDIR" == /tmp/navigator-* ]] && rm -rf -- "$TEMPDIR" || :'
].join(' && '); if ! command -v inotifywait >/dev/null 2>&1; then
sleep 300
rm -f -- "$ARCHIVE" || true
# Sweep everything matching PATTERN that's not in use
find "$ROOT" -mindepth 1 -maxdepth 1 -name "$PATTERN" -print0 | \
while IFS= read -r -d '' p; do
if command -v lsof >/dev/null 2>&1 && lsof -t -- "$p" >/dev/null 2>&1; then
continue
fi
rm -rf -- "$p"
done
[ -n "\${TEMPDIR:-}" ] && [[ "$TEMPDIR" == /tmp/navigator-* ]] && rm -rf -- "$TEMPDIR" || :
exit 0
fi
if ! timeout 1800 bash -lc '
inotifywait -q -m -e open --format "%e %f" -- "$DIR" |
while read ev f; do
if [ "$f" = "$BASE" ]; then exit 0; fi
done
'; then
find "$ROOT" -mindepth 1 -maxdepth 1 -name "$PATTERN" -print0 | \
while IFS= read -r -d '' p; do
if command -v lsof >/dev/null 2>&1 && lsof -t -- "$p" >/dev/null 2>&1; then
continue
fi
rm -rf -- "$p"
done
exit 0
fi
if command -v lsof >/dev/null 2>&1; then
# Ensure no process holds ARCHIVE open
sleep 1
while lsof -t -- "$ARCHIVE" >/dev/null 2>&1; do sleep 1; done
else
timeout 86400 bash -lc '
inotifywait -q -m -e close --format "%e %f" -- "$DIR" |
while read ev f; do
if [ "$f" = "$BASE" ]; then exit 0; fi
done
' || true
fi
rm -f -- "$ARCHIVE" || true
# (uncomment -mmin +5 to keep very fresh ones)
find "$ROOT" -mindepth 1 -maxdepth 1 -name "$PATTERN" -print0 | \
while IFS= read -r -d '' p; do
if command -v lsof >/dev/null 2>&1 && lsof -t -- "$p" >/dev/null 2>&1; then
continue
fi
rm -rf -- "$p"
done
[ -n "\${TEMPDIR:-}" ] && [[ "$TEMPDIR" == /tmp/navigator-* ]] && rm -rf -- "$TEMPDIR" || :
`;
const cmd = [ const cmd = [
'systemd-run', 'systemd-run',
'--property=CollectMode=inactive-or-failed', '--property=CollectMode=inactive-or-failed',
@ -180,12 +235,8 @@ export class NavContextMenu {
...(result['temp-dir'] ? ['--setenv=TEMPDIR=' + result['temp-dir']] : []), ...(result['temp-dir'] ? ['--setenv=TEMPDIR=' + result['temp-dir']] : []),
'/bin/bash','-lc', script '/bin/bash','-lc', script
]; ];
await cockpit.spawn(cmd, { superuser: 'require', err: 'out' });
await cockpit.spawn(cmd, { superuser: 'require', err: 'out' }).then(out => console.log(out));
console.log("scheduled cleanup:", unitName);
console.log("Deleting :", result['archive-path'], "in 30 minutes or after download starts.");
} }
const downloader = new NavDownloader(download_target); const downloader = new NavDownloader(download_target);
downloader.download(); downloader.download();
} }

View File

@ -1,3 +1,9 @@
cockpit-navigator (0.5.11-4bookworm) bookworm; urgency=medium
* build package
-- Rachit Hans <rhans@45drives.com> Tue, 16 Sep 2025 11:58:45 -0300
cockpit-navigator (0.5.11-3bookworm) bookworm; urgency=medium cockpit-navigator (0.5.11-3bookworm) bookworm; urgency=medium
* build package + fixed deletion method of tmp files * build package + fixed deletion method of tmp files

View File

@ -33,6 +33,8 @@ rm -rf %{buildroot}
/usr/share/cockpit/navigator/* /usr/share/cockpit/navigator/*
%changelog %changelog
* Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-4
- build package
* Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-3 * Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-3
- build package + fixed deletion method of tmp files - build package + fixed deletion method of tmp files
* Tue Sep 16 2025 Jordan Keough <jkeough@45drives.com> 0.5.11-2 * Tue Sep 16 2025 Jordan Keough <jkeough@45drives.com> 0.5.11-2

View File

@ -33,6 +33,8 @@ rm -rf %{buildroot}
/usr/share/cockpit/navigator/* /usr/share/cockpit/navigator/*
%changelog %changelog
* Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-4
- build package
* Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-3 * Tue Sep 16 2025 Rachit Hans <rhans@45drives.com> 0.5.11-3
- build package + fixed deletion method of tmp files - build package + fixed deletion method of tmp files
* Tue Sep 16 2025 Jordan Keough <jkeough@45drives.com> 0.5.11-2 * Tue Sep 16 2025 Jordan Keough <jkeough@45drives.com> 0.5.11-2

View File

@ -1,3 +1,9 @@
cockpit-navigator (0.5.11-4focal) focal; urgency=medium
* build package
-- Rachit Hans <rhans@45drives.com> Tue, 16 Sep 2025 11:58:45 -0300
cockpit-navigator (0.5.11-3focal) focal; urgency=medium cockpit-navigator (0.5.11-3focal) focal; urgency=medium
* build package + fixed deletion method of tmp files * build package + fixed deletion method of tmp files

View File

@ -1,3 +1,9 @@
cockpit-navigator (0.5.11-4jammy) jammy; urgency=medium
* build package
-- Rachit Hans <rhans@45drives.com> Tue, 16 Sep 2025 11:58:45 -0300
cockpit-navigator (0.5.11-3jammy) jammy; urgency=medium cockpit-navigator (0.5.11-3jammy) jammy; urgency=medium
* build package + fixed deletion method of tmp files * build package + fixed deletion method of tmp files