From 25aa4e5a8969edb5eaef90c3fe55b6f8d3be7ce9 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sun, 19 Aug 2012 18:35:10 +0000 Subject: [PATCH] E: add overwrite handling. Patch by Maxime Villard (rustyBSD) SVN revision: 75436 --- src/bin/e_fm_op.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bin/e_fm_op.c b/src/bin/e_fm_op.c index 291b8387b..cde5a574c 100644 --- a/src/bin/e_fm_op.c +++ b/src/bin/e_fm_op.c @@ -1521,11 +1521,22 @@ static int _e_fm_op_symlink_atom(E_Fm_Op_Task *task) { if (_e_fm_op_abort) return 1; + if (_e_fm_op_handle_overwrite(task)) return 1; E_FM_OP_DEBUG("Symlink: %s -> %s\n", task->src.name, task->dst.name); if (symlink(task->src.name, task->dst.name) != 0) - _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", task->src.name, task->dst.name); + { + if (errno == EEXIST) + { + if (unlink(task->dst.name) == -1) + _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot unlink '%s': %s.", task->dst.name); + if (symlink(task->src.name, task->dst.name) == -1) + _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", task->src.name, task->dst.name); + } + else + _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", task->src.name, task->dst.name); + } task->dst.done += REMOVECHUNKSIZE; _e_fm_op_update_progress(task, REMOVECHUNKSIZE, 0);