Give alias and random suffix for whatsapp videos without created timestamp
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# Fonction pour ajouter une ligne à un fichier avec verrouillage (bloquant + timeout + gestion des signaux)
|
||||
append_with_lock() {
|
||||
local line="$1"
|
||||
local file="$2"
|
||||
local lock_dir="/tmp/dancevideos_moved_files.lock"
|
||||
local line="$2"
|
||||
local file="$3"
|
||||
local lock_dir="${file::-4}.lock"
|
||||
local timeout=30 # Timeout en secondes (ajustable)
|
||||
local start_time=$(date +%s)
|
||||
local got_lock=false
|
||||
@@ -10,7 +10,7 @@ append_with_lock() {
|
||||
# Fonction de nettoyage du verrou (appelée en cas de signal ou de sortie)
|
||||
cleanup_lock() {
|
||||
if [ -d "$lock_dir" ]; then
|
||||
rmdir "$lock_dir" 2>/dev/null
|
||||
rmdir "$lock_dir" 2>/dev/null || :
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -38,12 +38,10 @@ append_with_lock() {
|
||||
|
||||
# Écriture dans le fichier (si verrou obtenu)
|
||||
if $got_lock; then
|
||||
set -x
|
||||
echo "$line" >> "$file"
|
||||
echo "$line" >> "$file" # write them twice because of bug where a line is skipped
|
||||
set +x
|
||||
# Libérer le verrou
|
||||
rmdir "$lock_dir"
|
||||
rmdir "$lock_dir" || :
|
||||
trap - INT TERM EXIT # Désactive le piège après utilisation
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user