Common SFTP failure due to local cache/live file mismatch

This is an issue I face quite often. I use Sublime to edit files on a server connected via sftp through Netdrive.

I will edit a file and having completed my task close it.
Then on the server I switch to another git branch or perhaps just revert the file.
I open the file locally (or say yes to a reload) and then sublime loads a truncated version of the file. I don’t think the size of the modification matters, adding or removing lines. The file visible on the NetDrive drive is truncated.

I can issue a touch command for the server file or delete it and recreated it, but I still get the same truncated source code in sublime. If I don’t move to the end of the file each time to check to see if it is truncated, then my site fails to load because of the syntax error. The only solution is to disconnect and then reconnect that particular drive and then everything is fine.

Is there a fix for this?
Is there an invalidate cache button/parameter hidden somewhere?
Could I have a batch file that I use to wipe out a certain local directory and thus force the file to be loaded from the server?

Let me ask this: Has any one else seen this behavior?

SFTP server does not notify to NetDrive about file changes. So NetDrive does not know about changes in remote instantly. At least you should refresh folder to detect file change.

But I think we can check about files changes every time user opens file even it takes a lot of traffic to server.

Thanks! I’ve tried to do refreshes and other things on my side to get it to sync up again, but haven’t had any luck. However yeah, if you could a compare of the modified date upon open that may help identify the situation. I just find it strange that the file is truncated when I reload it. SOMETHING obviously passes through upon a file change or upon reload you wouldn’t get a partial file, truncated in the middle. Were the local cache of the php file only out of date, that would be a recognizable stale cache situation I’d expect to see. In my situation, the source code just ends somewhere in the middle of the file.

As a developer, I’d be more than willing to assist in any diagnostics or debugging that may be needed to diagnose and resolve this.

Just another note. I had the problem again and instead of doing a refresh from within the Sublime open dialog, I did it from within an explorer window and the full file loaded. So you may have been exactly right in the diagnosis.