Uses mktemp to generate unique name in trashcan directory

This commit is contained in:
Robert Rothenberg 2011-06-18 13:26:37 +01:00
parent 5236943a74
commit 50cb5923c7

14
trash
View File

@ -15,7 +15,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
version="0.3.8 \$Id: trash 2011/06/18 13:04:58 BST rr@newfie $" version="0.3.9 \$Id: trash 2011/06/18 13:24:35 BST rr@newfie $"
progname=`basename $0` progname=`basename $0`
@ -233,15 +233,9 @@ function trash_file {
ext="" ext=""
fi fi
cnt=1 deletedfile=$(mktemp --tmpdir="${trashdir}/files" --suffix="${ext}" "${trashname}_XXXXXXXX" )
while [ -e "$trashdir/files/$trashname" ] || \ deletedbase=$( basename "${deletedfile}" )
[ -e "$trashdir/info/$trashname.trashinfo" ]; do deletedinfo="$trashdir/info/${deletedbase}.trashinfo"
trashname="${origname}_${cnt}${ext}"
let cnt=cnt+1
done
deletedfile="$trashdir/files/$trashname"
deletedinfo="$trashdir/info/$trashname.trashinfo"
canon=`url_encode "$filename"` canon=`url_encode "$filename"`