changeset 18861:5450f9217b97

fs-posix: fs_copy() didn't work with prefix= parameter
author Timo Sirainen <tss@iki.fi>
date Tue, 16 Jun 2015 00:16:42 +0300
parents cac29b3a1e96
children d255f8627d95
files src/lib-fs/fs-posix.c
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-fs/fs-posix.c	Mon Jun 15 14:55:03 2015 +0300
+++ b/src/lib-fs/fs-posix.c	Tue Jun 16 00:16:42 2015 +0300
@@ -624,28 +624,29 @@
 
 static int fs_posix_copy(struct fs_file *_src, struct fs_file *_dest)
 {
+	struct posix_fs_file *src = (struct posix_fs_file *)_src;
 	struct posix_fs_file *dest = (struct posix_fs_file *)_dest;
 	struct posix_fs *fs = (struct posix_fs *)_src->fs;
 	unsigned int try_count = 0;
 	int ret;
 
-	ret = link(_src->path, _dest->path);
+	ret = link(src->full_path, dest->full_path);
 	if (errno == EEXIST && dest->open_mode == FS_OPEN_MODE_REPLACE) {
 		/* destination file already exists - replace it */
-		if (unlink(_dest->path) < 0 && errno != ENOENT)
-			i_error("unlink(%s) failed: %m", _dest->path);
-		ret = link(_src->path, _dest->path);
+		if (unlink(dest->full_path) < 0 && errno != ENOENT)
+			i_error("unlink(%s) failed: %m", dest->full_path);
+		ret = link(src->full_path, dest->full_path);
 	}
 	while (ret < 0 && errno == ENOENT &&
 	       try_count <= MAX_MKDIR_RETRY_COUNT) {
-		if (fs_posix_mkdir_parents(fs, _dest->path) < 0)
+		if (fs_posix_mkdir_parents(fs, dest->full_path) < 0)
 			return -1;
-		ret = link(_src->path, _dest->path);
+		ret = link(src->full_path, dest->full_path);
 		try_count++;
 	}
 	if (ret < 0) {
 		fs_set_error(_src->fs, "link(%s, %s) failed: %m",
-			     _src->path, _dest->path);
+			     src->full_path, dest->full_path);
 		return -1;
 	}
 	return 0;