1
1

Merge branch '2924_preserve_dir_attributes'

* 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.
Этот коммит содержится в:
Andrew Borodin 2012-11-29 14:45:50 +04:00
родитель 4ee4959cea 33dbb1338e
Коммит f0d1d91864

Просмотреть файл

@ -1933,7 +1933,7 @@ copy_file_file (FileOpTotalContext * tctx, FileOpContext * ctx,
function calls */ function calls */
FileProgressStatus 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) gboolean toplevel, gboolean move_over, gboolean do_delete, GSList * parent_dirs)
{ {
struct dirent *next; struct dirent *next;
@ -1943,13 +1943,11 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
FileProgressStatus return_status = FILE_CONT; FileProgressStatus return_status = FILE_CONT;
struct utimbuf utb; struct utimbuf utb;
struct link *lp; struct link *lp;
char *d;
vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL; vfs_path_t *src_vpath, *dst_vpath, *dest_dir_vpath = NULL;
gboolean do_mkdir = TRUE;
d = g_strdup (_d);
src_vpath = vfs_path_from_str (s); 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 */ /* First get the mode of the source dir */
@ -2030,8 +2028,7 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
goto ret; goto ret;
} }
} }
dest_dir = d; dest_dir = g_strdup (d);
d = NULL;
} }
else else
{ {
@ -2059,37 +2056,40 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
} }
/* Dive into subdir if exists */ /* Dive into subdir if exists */
if (toplevel && ctx->dive_into_subdirs) if (toplevel && ctx->dive_into_subdirs)
{
dest_dir = mc_build_filename (d, x_basename (s), NULL); dest_dir = mc_build_filename (d, x_basename (s), NULL);
}
else else
{ {
dest_dir = d; dest_dir = g_strdup (d);
d = NULL; do_mkdir = FALSE;
goto dont_mkdir;
} }
} }
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); dest_dir_vpath = vfs_path_from_str (dest_dir);
mc_stat (dest_dir_vpath, &buf);
lp->vfs = vfs_path_get_by_index (dest_dir_vpath, -1)->class; if (do_mkdir)
lp->ino = buf.st_ino; {
lp->dev = buf.st_dev; while (my_mkdir (dest_dir_vpath, (cbuf.st_mode & ctx->umask_kill) | S_IRWXU) != 0)
dest_dirs = g_slist_prepend (dest_dirs, lp); {
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) if (ctx->preserve_uidgid)
{ {
@ -2109,7 +2109,6 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
} }
} }
dont_mkdir:
/* open the source dir for reading */ /* open the source dir for reading */
reading = mc_opendir (src_vpath); reading = mc_opendir (src_vpath);
if (reading == NULL) if (reading == NULL)
@ -2195,7 +2194,6 @@ copy_dir_dir (FileOpTotalContext * tctx, FileOpContext * ctx, const char *s, con
free_link (parent_dirs->data); free_link (parent_dirs->data);
g_slist_free_1 (parent_dirs); g_slist_free_1 (parent_dirs);
ret_fast: ret_fast:
g_free (d);
vfs_path_free (src_vpath); vfs_path_free (src_vpath);
vfs_path_free (dst_vpath); vfs_path_free (dst_vpath);
return return_status; return return_status;