michaellukashov / Far-NetBox

SFTP/SCP/FTP/FTPS/WebDAV/S3 client for Far Manager 3 (http://farmanager.com/)
https://forum.farmanager.com/viewtopic.php?t=6317
GNU General Public License v2.0
157 stars 52 forks source link

Повторная отправка put после редактирования файла на сервере в v2.1.44.404 #161

Open VictorVG opened 9 years ago

VictorVG commented 9 years ago

Сообщение о наблюдении явления с http://forum.ru-board.com/topic.cgi?forum=5&topic=31718&start=7460#10:

_Alexyz21_

_Victor_VG_ NB по прежнему при сохранении файла после редактирования на ФТП сервере заливает изменённый файл 2 раза подряд.

попросил выслать лог http://forum.ru-board.com/topic.cgi?forum=5&topic=31718&start=7449&limit=1&m=1#1 - похоже что буфер записи дважды скидывается (?):

. 2015-08-22 14:27:37.593 NetBox Version 2.1.43 (Build 400) (OS 5.1.2600 Service Pack 2 - Microsoft Windows XP)
. 2015-08-22 14:27:37.593 Configuration: NetBox 3\
. 2015-08-22 14:27:37.593 Working directory: Z:\Temp
. 2015-08-22 14:27:37.593 Warning: System option "Automatically adjust clock for Daylight Saving Time" is disabled, timestamps will not be represented correctly
. 2015-08-22 14:27:37.593 Login time: 22.08.2015 14:27:37
. 2015-08-22 14:27:37.593 Host name: xxx.xxx.xxx.xxx (Port: 21)
. 2015-08-22 14:27:37.593 Transfer Protocol: FTP
. 2015-08-22 14:27:37.593 Code Page: 65001
. 2015-08-22 14:27:37.593 Ping type: C, Ping interval: 60 sec; Timeout: 30 sec
. 2015-08-22 14:27:37.593 Disable Nagle: Yes
. 2015-08-22 14:27:37.593 Proxy: none
. 2015-08-22 14:27:37.593 Send buffer: 262144
. 2015-08-22 14:27:37.593 UTF: 0
. 2015-08-22 14:27:37.593 FTP: FTPS: None; Passive: No [Force IP: A]; MLSD: A  [List all: A]
. 2015-08-22 14:27:37.593 Local directory: default, Remote directory: /1, Update: No, Cache: No
. 2015-08-22 14:27:37.593 Cache directory changes: No, Permanent: No
. 2015-08-22 14:27:37.593 Timezone offset: 0h 0m
. 2015-08-22 14:27:37.609 Connecting to xxx.xxx.xxx.xxx ...
. 2015-08-22 14:27:37.609 Connected with xxx.xxx.xxx.xxx. Waiting for welcome message...
< 2015-08-22 14:27:37.625 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
< 2015-08-22 14:27:37.625 220-You are user number 2 of 100 allowed.
< 2015-08-22 14:27:37.625 220-Local time is now 14:27. Server port: 21.
< 2015-08-22 14:27:37.625 220-This is a private system - No anonymous login
< 2015-08-22 14:27:37.625 220 You will be disconnected after 15 minutes of inactivity.
> 2015-08-22 14:27:37.625 USER xxx
< 2015-08-22 14:27:37.671 331 User xxx OK. Password required
> 2015-08-22 14:27:37.671 PASS ************
< 2015-08-22 14:27:37.671 230 OK. Current restricted directory is /
> 2015-08-22 14:27:37.671 SYST
< 2015-08-22 14:27:37.671 215 UNIX Type: L8
> 2015-08-22 14:27:37.671 FEAT
< 2015-08-22 14:27:37.671 211-Extensions supported:
< 2015-08-22 14:27:37.671  EPRT
< 2015-08-22 14:27:37.671  IDLE
< 2015-08-22 14:27:37.671  MDTM
< 2015-08-22 14:27:37.671  SIZE
< 2015-08-22 14:27:37.671  MFMT
< 2015-08-22 14:27:37.671  REST STREAM
< 2015-08-22 14:27:37.671  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
< 2015-08-22 14:27:37.671  MLSD
< 2015-08-22 14:27:37.671  AUTH TLS
< 2015-08-22 14:27:37.671  PBSZ
< 2015-08-22 14:27:37.671  PROT
< 2015-08-22 14:27:37.671  UTF8
< 2015-08-22 14:27:37.671  ESTA
< 2015-08-22 14:27:37.671  PASV
< 2015-08-22 14:27:37.671  EPSV
< 2015-08-22 14:27:37.671  SPSV
< 2015-08-22 14:27:37.671  ESTP
< 2015-08-22 14:27:37.671 211 End.
> 2015-08-22 14:27:37.671 OPTS UTF8 ON
< 2015-08-22 14:27:37.671 200 OK, UTF-8 enabled
. 2015-08-22 14:27:37.687 Connected
. 2015-08-22 14:27:37.687 Got reply 1 to the command 1
. 2015-08-22 14:27:37.687 Using FTP protocol.
. 2015-08-22 14:27:37.687 Doing startup conversation with host.
> 2015-08-22 14:27:37.687 PWD
< 2015-08-22 14:27:37.687 257 "/" is your current location
. 2015-08-22 14:27:37.687 Got reply 1 to the command 16
. 2015-08-22 14:27:37.687 Changing directory to "/1".
> 2015-08-22 14:27:37.687 CWD /1
< 2015-08-22 14:27:37.734 250 OK. Current directory is /1
. 2015-08-22 14:27:37.734 Got reply 1 to the command 16
. 2015-08-22 14:27:37.734 Getting current directory name.
> 2015-08-22 14:27:37.734 PWD
< 2015-08-22 14:27:37.750 257 "/1" is your current location
. 2015-08-22 14:27:37.750 Got reply 1 to the command 16
. 2015-08-22 14:27:37.796 Retrieving directory listing...
> 2015-08-22 14:27:37.796 TYPE A
< 2015-08-22 14:27:37.796 200 TYPE is now ASCII
> 2015-08-22 14:27:37.796 PORT 192,168,1,2,12,167
< 2015-08-22 14:27:37.796 200 PORT command successful
> 2015-08-22 14:27:37.796 MLSD
< 2015-08-22 14:27:37.796 150 Connecting to port 3239
< 2015-08-22 14:27:37.812 226-Options: -a -l  
< 2015-08-22 14:27:37.875 226 56 matches total
. 2015-08-22 14:27:37.875 type=cdir;sizd=4096;modify=20150718180429;UNIX.mode=0755;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf455; .
. 2015-08-22 14:27:37.875 type=pdir;sizd=4096;modify=20130926112912;UNIX.mode=0775;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf454; ..
. 2015-08-22 14:27:37.875 type=file;size=163351;modify=20150427084320;UNIX.mode=0664;UNIX.uid=99;UNIX.gid=99;unique=fd04gbab62f; 3.txt
. 2015-08-22 14:27:37.953 Directory listing successful
. 2015-08-22 14:27:37.953 Got reply 1 to the command 2
. 2015-08-22 14:27:37.953 ..;D;0;1899-12-30T1190:02:47.297Z;"" [0];"" [0];---------;0
. 2015-08-22 14:27:37.953 3.txt;-;163351;2015-04-27T08:43:20.000Z;"99" [0];"99" [0];rw-rw-r--;0
. 2015-08-22 14:27:37.968 Startup conversation with host finished.
. 2015-08-22 14:27:46.859 Copying 1 files/directories to local directory "Z:\Temp\F3TCEA9.tmp"
. 2015-08-22 14:27:46.859   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: &#58136;; Resume: N (102400); CalcS: Yes; Mask:  
. 2015-08-22 14:27:46.859   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2015-08-22 14:27:46.859   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2015-08-22 14:27:46.859 File: '/1/3.txt' [2015-04-27T08:43:20.000Z] [163351]
. 2015-08-22 14:27:46.859 Copying "/1/3.txt" to local directory started.
. 2015-08-22 14:27:46.859 Binary transfer mode selected.
. 2015-08-22 14:27:46.859 Starting download of /1/3.txt
> 2015-08-22 14:27:46.859 TYPE I
< 2015-08-22 14:27:46.921 200 TYPE is now 8-bit binary
> 2015-08-22 14:27:46.921 PORT 192,168,1,2,12,170
< 2015-08-22 14:27:46.921 200 PORT command successful
> 2015-08-22 14:27:46.921 RETR 3.txt
< 2015-08-22 14:27:46.921 150-Connecting to port 3242
< 2015-08-22 14:27:46.921 150 159.5 kbytes to download
< 2015-08-22 14:27:47.062 226-File successfully transferred
< 2015-08-22 14:27:47.062 226 0.159 seconds (measured here), 0.98 Mbytes per second
. 2015-08-22 14:27:47.125 Download successful
. 2015-08-22 14:27:47.125 Got reply 1 to the command 4
. 2015-08-22 14:27:47.125 Transfer done: '3.txt' [163351]
. 2015-08-22 14:27:55.171 Copying 1 files/directories to remote directory "/1"
. 2015-08-22 14:27:55.171   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: &#65773;&#65709;&#65688;; Resume: N (102400); CalcS: Yes; Mask:  
. 2015-08-22 14:27:55.171   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2015-08-22 14:27:55.171   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2015-08-22 14:27:55.171 File: 'Z:\Temp\F3TCEA9.tmp\3.txt' [2015-08-22T11:27:55.171Z] [163352]
. 2015-08-22 14:27:55.171 Copying "Z:\Temp\F3TCEA9.tmp\3.txt" to remote directory started.
. 2015-08-22 14:27:55.171 Binary transfer mode selected.
. 2015-08-22 14:27:55.171 Starting upload of Z:\Temp\F3TCEA9.tmp\3.txt
> 2015-08-22 14:27:55.171 TYPE I
< 2015-08-22 14:27:55.234 200 TYPE is now 8-bit binary
> 2015-08-22 14:27:55.234 PORT 192,168,1,2,12,171
< 2015-08-22 14:27:55.234 200 PORT command successful
> 2015-08-22 14:27:55.234 STOR 3.txt
< 2015-08-22 14:27:55.234 150 Connecting to port 3243
< 2015-08-22 14:27:56.187 226-File successfully transferred
< 2015-08-22 14:27:56.187 226 0.969 seconds (measured here), 164.57 Kbytes per second
> 2015-08-22 14:27:56.187 MFMT 20150822112755 3.txt
< 2015-08-22 14:27:56.187 213 UTIME OK
. 2015-08-22 14:27:56.296 Upload successful
. 2015-08-22 14:27:56.296 Got reply 1 to the command 4
. 2015-08-22 14:27:56.296 Transfer done: 'Z:\Temp\F3TCEA9.tmp\3.txt' [163352]
. 2015-08-22 14:27:56.296 Copying 1 files/directories to remote directory "/1"
. 2015-08-22 14:27:56.296   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: &#58656;; Resume: N (102400); CalcS: Yes; Mask:  
. 2015-08-22 14:27:56.296   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2015-08-22 14:27:56.296   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2015-08-22 14:27:56.312 File: 'Z:\Temp\F3TCEA9.tmp\3.txt' [2015-08-22T11:27:55.171Z] [163352]
. 2015-08-22 14:27:56.312 Copying "Z:\Temp\F3TCEA9.tmp\3.txt" to remote directory started.
. 2015-08-22 14:27:56.312 Binary transfer mode selected.
. 2015-08-22 14:27:56.312 Starting upload of Z:\Temp\F3TCEA9.tmp\3.txt
> 2015-08-22 14:27:56.312 TYPE A
< 2015-08-22 14:27:56.406 200 TYPE is now ASCII
> 2015-08-22 14:27:56.406 PORT 192,168,1,2,12,172
< 2015-08-22 14:27:56.406 200 PORT command successful
> 2015-08-22 14:27:56.406 MLSD
< 2015-08-22 14:27:56.421 150 Connecting to port 3244
< 2015-08-22 14:27:56.421 226-Options: -a -l  
< 2015-08-22 14:27:56.421 226 56 matches total
. 2015-08-22 14:27:56.484 type=cdir;sizd=4096;modify=20150718180429;UNIX.mode=0755;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf455; .
. 2015-08-22 14:27:56.484 type=pdir;sizd=4096;modify=20130926112912;UNIX.mode=0775;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf454; ..
. 2015-08-22 14:27:56.484 type=file;size=163352;modify=20150822112755;UNIX.mode=0664;UNIX.uid=99;UNIX.gid=99;unique=fd04gbab62f; 3.txt
> 2015-08-22 14:27:56.515 TYPE I
< 2015-08-22 14:27:56.515 200 TYPE is now 8-bit binary
> 2015-08-22 14:27:56.515 PORT 192,168,1,2,12,173
< 2015-08-22 14:27:56.515 200 PORT command successful
> 2015-08-22 14:27:56.578 STOR 3.txt
< 2015-08-22 14:27:56.578 150 Connecting to port 3245
< 2015-08-22 14:27:57.515 226-File successfully transferred
< 2015-08-22 14:27:57.515 226 0.975 seconds (measured here), 163.65 Kbytes per second
> 2015-08-22 14:27:57.515 MFMT 20150822112755 3.txt
< 2015-08-22 14:27:57.531 213 UTIME OK
. 2015-08-22 14:27:57.578 Upload successful
. 2015-08-22 14:27:57.578 Got reply 1 to the command 4
. 2015-08-22 14:27:57.578 Transfer done: 'Z:\Temp\F3TCEA9.tmp\3.txt' [163352]
. 2015-08-22 14:27:57.578 Retrieving directory listing...
> 2015-08-22 14:27:57.578 TYPE A
< 2015-08-22 14:27:57.578 200 TYPE is now ASCII
> 2015-08-22 14:27:57.640 PORT 192,168,1,2,12,174
< 2015-08-22 14:27:57.640 200 PORT command successful
> 2015-08-22 14:27:57.640 MLSD
< 2015-08-22 14:27:57.640 150 Connecting to port 3246
< 2015-08-22 14:27:57.640 226-Options: -a -l  
< 2015-08-22 14:27:57.640 226 56 matches total
. 2015-08-22 14:27:57.640 type=cdir;sizd=4096;modify=20150718180429;UNIX.mode=0755;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf455; .
. 2015-08-22 14:27:57.640 type=pdir;sizd=4096;modify=20130926112912;UNIX.mode=0775;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf454; ..
. 2015-08-22 14:27:57.640 type=file;size=163352;modify=20150822112755;UNIX.mode=0664;UNIX.uid=99;UNIX.gid=99;unique=fd04gbab62f; 3.txt
. 2015-08-22 14:27:57.671 Directory listing successful
. 2015-08-22 14:27:57.671 Got reply 1 to the command 2
. 2015-08-22 14:27:57.671 ..;D;0;1899-12-30T1190:02:47.297Z;"" [0];"" [0];---------;0
. 2015-08-22 14:27:57.671 3.txt;-;163352;2015-08-22T11:27:55.000Z;"99" [0];"99" [0];rw-rw-r--;0
. 2015-08-22 14:27:57.687 Getting current directory name.
. 2015-08-22 14:27:57.687 Retrieving directory listing...
> 2015-08-22 14:27:57.687 TYPE A
< 2015-08-22 14:27:57.703 200 TYPE is now ASCII
> 2015-08-22 14:27:57.703 PORT 192,168,1,2,12,175
< 2015-08-22 14:27:57.703 200 PORT command successful
> 2015-08-22 14:27:57.703 MLSD
< 2015-08-22 14:27:57.718 150 Connecting to port 3247
< 2015-08-22 14:27:57.765 226-Options: -a -l  
< 2015-08-22 14:27:57.765 226 56 matches total
. 2015-08-22 14:27:57.781 type=cdir;sizd=4096;modify=20150718180429;UNIX.mode=0755;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf455; .
. 2015-08-22 14:27:57.781 type=pdir;sizd=4096;modify=20130926112912;UNIX.mode=0775;UNIX.uid=99;UNIX.gid=99;unique=fd04gbdf454; ..
. 2015-08-22 14:27:57.781 type=file;size=163352;modify=20150822112755;UNIX.mode=0664;UNIX.uid=99;UNIX.gid=99;unique=fd04gbab62f; 3.txt
. 2015-08-22 14:27:57.812 Directory listing successful
. 2015-08-22 14:27:57.812 Got reply 1 to the command 2
. 2015-08-22 14:27:57.812 ..;D;0;1899-12-30T1190:02:47.297Z;"" [0];"" [0];---------;0
. 2015-08-22 14:27:57.812 3.txt;-;163352;2015-08-22T11:27:55.000Z;"99" [0];"99" [0];rw-rw-r--;0
> 2015-08-22 14:28:02.625 QUIT
VictorVG commented 9 years ago

Если не получим инструменты позволяющие отследить факт что внешний редактор сохранил файл (http://forum.farmanager.com/viewtopic.php?f=8&p=132241#p132241) к примеру тот же мьютекс или вызов API, то может поступить чуть иначе - периодически в фоновом потоке проверять факт изменения времени последней записи файла и сверять со временем передачи файла во внешний редактор. Логика - если время последней записи на сервере новее чем время передачи файла внешнему редактору, то скорее всего файл сохранён им и перезапись не требуется.

VictorVG commented 9 years ago

Получили поправку (http://forum.ru-board.com/topic.cgi?forum=5&topic=31718&start=7500#4) к описанию события, но думаю стоит рассмотреть и более общий вариант:

_Alexyz21_

_Victor_VG_ "О двойном сохранении (аплоаде) файла" Файл открывается не во внешнем редакторе, а в редакторе Фара.

z0hm commented 9 years ago

Что-то не в тот лес грибники пошли :) Вот изначальный рапорт:

WinXPSP2, FAR3.0.4409, NetBox 2.1.43 (build 400) Заходим на ФТП, F4 на текстовом файле, редактируем, ESC, отвечаем - да, сохранить - NB заливает изменённый файл на ФТП дважды.

Т.е. 2-ой аплоад происходит при редактировании файла на ФТП сервере в редакторе Фара. Из лога, кстати, это видно - файл сначала закачивается во временную папку, а затем дважды аплоадится на ФТП сервер. Имхо это результат недавнего исправления несохранения файла при редактировании на сервере (на форуме фара обсуждалось). У меня та версия сохраняла нормально.

VictorVG commented 9 years ago

Вот с этим и возимся - http://forum.farmanager.com/viewtopic.php?f=8&p=132241#p132241 и это я обобщил ситуацию на случай если используемый не встроенный, а внешний по отношению к фар редактор умет сохранять данные по сети сам. Например IDM UltraEdit, IDM UEStudio, Visicom Media AceHTML, Allaire HomeSuite - любой из них это умеет и если используются такие редакторы, то нам надо самим отследить что они записали файл на сервер т.к. они не сообщают во внешнее приложение что произвели запись, хотя IDM и можно об этом "попросить" через их макросы, а Visicom/Allaire насколько помню нет.