Skip to content

Commit

Permalink
Remove tempDir on Ctrl+C
Browse files Browse the repository at this point in the history
  • Loading branch information
eismann-freenet committed Sep 13, 2023
1 parent 4a5cc13 commit e5285c9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 1fichier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,23 @@ removeCookies() {
}


cancelDownload() {
echo "Download cancelled."
removeTempDir "${lastTempDir}"
exit 1
}


downloadFile() {
trap cancelDownload SIGINT SIGTERM

local url=${1}
echo "Processing \"${url}\""...
echo -n "Search for a circuit without wait time..."

local baseDir=$(pwd)
local tempDir=${baseDir}/$(mktemp --directory "tmp.XXX")
lastTempDir=${tempDir}

local filenameRegEx='>Filename :<.*<td class="normal">(.*)</td>.*>Date :<'
local maxCount=500
Expand Down Expand Up @@ -129,6 +139,8 @@ downloadFile() {
failedDownload "${baseDir}" "${url}"
fi
removeTempDir "${tempDir}"

trap - SIGINT SIGTERM
}


Expand All @@ -147,6 +159,7 @@ if [ "${torPort}" = "" ] ; then
fi
echo "Tor is listening on port ${torPort}"

lastTempDir=
downloadSource=${1}
if [[ "${downloadSource}" =~ "1fichier.com" ]] ; then
downloadFile "${downloadSource}"
Expand Down

0 comments on commit e5285c9

Please sign in to comment.