From 3b631ed12e9566e60ceab7826b4ab1e1c58e55f4 Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Mon, 4 May 1998 09:29:52 +0000 Subject: [PATCH] Fix the ftp bug reported by Andrej Borsenkow. If we have to keep O_EXCL in retrieve_file_start2 then I will find a different fix. Mon May 4 10:27:49 1998 Norbert Warmuth * ftpfs.c (retrieve_file_start2): Don't create target file O_EXCL, in copy_file_file we check existance of the target file and know that we want to truncate it. Mon May 4 10:21:31 1998 Norbert Warmuth * file.c (copy_file_file): Schedule deletion of short target file only when we created or truncated the target file and not already when we decided to overwrite an existing file. --- src/ChangeLog | 6 ++++++ src/file.c | 10 +++++++++- vfs/ChangeLog | 6 ++++++ vfs/ftpfs.c | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ad4170b4c..92b54eaf7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Mon May 4 10:21:31 1998 Norbert Warmuth + + * file.c (copy_file_file): Schedule deletion of short target file + only when we created or truncated the target file and not already + when we decided to overwrite an existing file. + 1998-05-03 Miguel de Icaza * boxes.c (task_cb): Use kill, not INT, as we are catching INT in diff --git a/src/file.c b/src/file.c index 69028c049..4f200bc16 100644 --- a/src/file.c +++ b/src/file.c @@ -1078,8 +1078,8 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite) goto ret; } resources |= 2; /* dst_path exists/dst_path opened */ + resources |= 4; /* remove short file */ } - resources |= 4; /* remove short file */ appending = do_append; do_append = 0; @@ -1163,6 +1163,14 @@ copy_file_file (char *src_path, char *dst_path, int ask_overwrite) i = 0; break; } + + /* the first time we reach this line the target file has been created + or truncated and we actually have a short target file. + Do we really want to delete the target file when the ftp transfer + fails? If we don't delete it we would be able to use reget later. + (Norbert) */ + resources |= 4; /* remove short file */ + if (i && size != MCERR_DATA_ON_STDIN){ n_read_total += size; diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 2fec9cf33..43f1a9289 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,9 @@ +Mon May 4 10:27:49 1998 Norbert Warmuth + + * ftpfs.c (retrieve_file_start2): Don't create target file O_EXCL, + in copy_file_file we check existance of the target file and know + that we want to truncate it. + 1998-04-29 Miguel de Icaza * tar.c (read_header): Mark regular files with S_IFREG. diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index a246adefd..d92669786 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1630,7 +1630,7 @@ int retrieve_file_start(struct ftpentry *fe) int retrieve_file_start2(struct ftpentry *fe) { - remotelocal_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600); + remotelocal_handle = open(fe->local_filename, O_RDWR | O_CREAT | O_TRUNC, 0600); if (remotelocal_handle == -1) { ftpfserrno = EIO; free(fe->local_filename);