Ticket #3985: preserve timestamp for synlinks.

* (local_utime): pass AT_SYMLINK_NOFOLLOW to utimensat() to update
    timestamps of the link,  rather  than the file to which it refers.
  * (move_file_file): preserve timestamp of the link.
  * (copy_file_file): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-04-03 16:15:44 +03:00
parent 9436bd1fa4
commit 109af564bc
2 changed files with 14 additions and 2 deletions

View File

@ -1251,7 +1251,16 @@ move_file_file (const WPanel * panel, file_op_total_context_t * tctx, file_op_co
{
return_status = make_symlink (ctx, s, d);
if (return_status == FILE_CONT)
{
if (ctx->preserve)
{
mc_timesbuf_t times;
get_times (&src_stat, &times);
mc_utime (dst_vpath, &times);
}
goto retry_src_remove;
}
goto ret;
}
@ -2286,6 +2295,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
}
}
get_times (&src_stat, &times);
if (!ctx->do_append)
{
/* Check the hardlinks */
@ -2310,6 +2321,8 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
if (S_ISLNK (src_stat.st_mode))
{
return_status = make_symlink (ctx, src_path, dst_path);
if (return_status == FILE_CONT && ctx->preserve)
mc_utime (dst_vpath, &times);
goto ret_fast;
}
@ -2411,7 +2424,6 @@ copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx,
src_mode = src_stat.st_mode;
src_uid = src_stat.st_uid;
src_gid = src_stat.st_gid;
get_times (&src_stat, &times);
file_size = src_stat.st_size;
open_flags = O_WRONLY;

View File

@ -200,7 +200,7 @@ local_utime (const vfs_path_t * vpath, mc_timesbuf_t * times)
path_element = vfs_path_get_by_index (vpath, -1);
#ifdef HAVE_UTIMENSAT
ret = utimensat (AT_FDCWD, path_element->path, *times, 0);
ret = utimensat (AT_FDCWD, path_element->path, *times, AT_SYMLINK_NOFOLLOW);
#else
ret = utime (path_element->path, times);
#endif