mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Merge branch '2924_preserve_dir_attributes' into 4.8.1-stable
* 2924_preserve_dir_attributes: (copy_dir_dir): get rid of extra string duplication. (copy_dir_dir): refactoring: get rid of goto dont_mkdir. Ticket #2924: attributes of existing directories are never preserved.
This commit is contained in:
commit
65569af255
@ -1920,7 +1920,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
|
||||
function calls */
|
||||
|
||||
FileProgressStatus
|
||||
copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, const char *_d,
|
||||
copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, const char *d,
|
||||
gboolean toplevel, gboolean move_over, gboolean do_delete, GSList * parent_dirs)
|
||||
{
|
||||
struct dirent *next;
|
||||
@ -1930,13 +1930,11 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
FileProgressStatus return_status = FILE_CONT;
|
||||
struct utimbuf utb;
|
||||
struct link *lp;
|
||||
char *d;
|
||||
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
|
||||
|
||||
d = g_strdup (_d);
|
||||
gboolean do_mkdir = TRUE;
|
||||
|
||||
src_vpath = vfs_path_from_str (s);
|
||||
dst_vpath = vfs_path_from_str (_d);
|
||||
dst_vpath = vfs_path_from_str (d);
|
||||
|
||||
/* First get the mode of the source dir */
|
||||
|
||||
@ -2017,8 +2015,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
dest_dir = d;
|
||||
d = NULL;
|
||||
dest_dir = g_strdup (d);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2046,37 +2043,40 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
}
|
||||
/* Dive into subdir if exists */
|
||||
if (toplevel && ctx->dive_into_subdirs)
|
||||
{
|
||||
dest_dir = mc_build_filename (d, x_basename (s), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest_dir = d;
|
||||
d = NULL;
|
||||
goto dont_mkdir;
|
||||
dest_dir = g_strdup (d);
|
||||
do_mkdir = FALSE;
|
||||
}
|
||||
}
|
||||
dest_dir_vpath = vfs_path_from_str (dest_dir);
|
||||
while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
|
||||
{
|
||||
if (ctx->skip_all)
|
||||
return_status = FILE_SKIPALL;
|
||||
else
|
||||
{
|
||||
return_status = file_error (_("Cannot create target directory \"%s\"\n%s"), dest_dir);
|
||||
if (return_status == FILE_SKIPALL)
|
||||
ctx->skip_all = TRUE;
|
||||
}
|
||||
if (return_status != FILE_RETRY)
|
||||
goto ret;
|
||||
}
|
||||
|
||||
lp = g_new0 (struct link, 1);
|
||||
mc_stat (dest_dir_vpath, &buf);
|
||||
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class;
|
||||
lp->ino = buf.st_ino;
|
||||
lp->dev = buf.st_dev;
|
||||
dest_dirs = g_slist_prepend (dest_dirs, lp);
|
||||
dest_dir_vpath = vfs_path_from_str (dest_dir);
|
||||
|
||||
if (do_mkdir)
|
||||
{
|
||||
while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
|
||||
{
|
||||
if (ctx->skip_all)
|
||||
return_status = FILE_SKIPALL;
|
||||
else
|
||||
{
|
||||
return_status =
|
||||
file_error (_("Cannot create target directory \"%s\"\n%s"), dest_dir);
|
||||
if (return_status == FILE_SKIPALL)
|
||||
ctx->skip_all = TRUE;
|
||||
}
|
||||
if (return_status != FILE_RETRY)
|
||||
goto ret;
|
||||
}
|
||||
|
||||
lp = g_new0 (struct link, 1);
|
||||
mc_stat (dest_dir_vpath, &buf);
|
||||
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class;
|
||||
lp->ino = buf.st_ino;
|
||||
lp->dev = buf.st_dev;
|
||||
dest_dirs = g_slist_prepend (dest_dirs, lp);
|
||||
}
|
||||
|
||||
if (ctx->preserve_uidgid)
|
||||
{
|
||||
@ -2096,7 +2096,6 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
}
|
||||
}
|
||||
|
||||
dont_mkdir:
|
||||
/* open the source dir for reading */
|
||||
reading = mc_opendir (src_vpath);
|
||||
if (reading == NULL)
|
||||
@ -2182,7 +2181,6 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
|
||||
free_link (parent_dirs->data);
|
||||
g_slist_free_1 (parent_dirs);
|
||||
ret_fast:
|
||||
g_free (d);
|
||||
vfs_path_free (src_vpath);
|
||||
vfs_path_free (dst_vpath);
|
||||
return return_status;
|
||||
|
Loading…
Reference in New Issue
Block a user