weex (2.6.1-7) src/ftpmain.c

Summary

 src/ftpmain.c |   29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

    
download this patch

Patch contents

--- weex-2.6.1.orig/src/ftpmain.c
+++ weex-2.6.1/src/ftpmain.c
@@ -256,6 +256,11 @@
 		free(temp);
 		return(-1);
 	}
+	if(authorization_name[host_number]){
+	  while(!FtpAuthorize(authorization_name[host_number], ftp_buf)){
+	    fprintf(stderr,_("Authorization failed; try again\n\n"));
+	  }
+	}
 	return(0);
 }
 
@@ -381,7 +386,7 @@
 		   local_data[i].date>remote_data[remote_num].date ||
 		  (local_data[i].date==remote_data[remote_num].date &&
 		   local_data[i].time>remote_data[remote_num].time)){
-			if(!overwrite_ok[host_number]){
+			if(!overwrite_ok[host_number] && !rename_ok[host_number]){
 				ftp_remove(file_name,dir_nest,&dir_removed_file);
 			}
 			if(is_ascii_file(file_name)){
@@ -400,11 +405,16 @@
 				}
 			}
 			if(!opt_test){
+			        int success = 0;
 				opt_silent_bak=opt_silent;
 				if(cfg_silent[host_number]){
 					opt_silent=1;
 				}
-				put_temp=str_concat(current_dir[REMOTE],file_name,NULL);
+				if (rename_ok[host_number]) {
+				  put_temp=str_concat(current_dir[REMOTE],"weex.tmp",NULL);
+				} else {
+				  put_temp=str_concat(current_dir[REMOTE],file_name,NULL);
+				}
 				for(j=0;;j++){
 					if(FtpPut(local_data[i].name,put_temp,trans_mode,ftp_buf)==1){
 						if(log_detail_level[host_number]>=3){
@@ -434,6 +444,7 @@
 							}
 							free(mode_temp);
 						}
+						success = 1;
 						break;
 					}
 					if(j>=max_retry_to_send[host_number]){
@@ -449,6 +460,20 @@
 					free(temp);
 					fprintf(stderr,_("Retrying...\n"));
 				}
+				if (success && rename_ok[host_number]) {
+				  char *put_temp2;
+				  if(!overwrite_ok[host_number]){
+				    ftp_remove(file_name,dir_nest,&dir_removed_file);
+				  }
+				  put_temp2 = str_concat(current_dir[REMOTE],file_name,NULL);
+				  if (!FtpRename(put_temp, put_temp2, ftp_buf)) {
+				    fprintf(stderr,_("Cannot rename temporary file to `%s%s'.\n"),current_dir[REMOTE],file_name);
+				    temp=str_dup_printf(_("Sending failed: %s%s"),current_dir[REMOTE],file_name);
+				    log_write(temp);
+				    free(temp);
+				  }
+				  free(put_temp2);
+				}
 				free(put_temp);
 				opt_silent=opt_silent_bak;
 			}