mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-12 19:03:10 +03:00
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:
parent
9436bd1fa4
commit
109af564bc
@ -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, ×);
|
||||
mc_utime (dst_vpath, ×);
|
||||
}
|
||||
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, ×);
|
||||
|
||||
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, ×);
|
||||
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, ×);
|
||||
file_size = src_stat.st_size;
|
||||
|
||||
open_flags = O_WRONLY;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user