Skip to content

Faulty error message on paste/drop on Local Files with different file encoding

Bugzilla Link 525274
Status NEW
Importance P3 normal
Reported Sep 27, 2017 11:24 EDT
Modified Sep 27, 2017 11:24 EDT
Version 4.2
Reporter Ralf Pakosch

Description

Created attachment 270703
Possible cause of faulty exception in LocalFileService.

Hi,

I've implemented a custom system type with a custom ISystemRemoteElementAdapter.
ISystemRemoteElementAdapter#doDrag(Object, boolean, IProgressMonitor) returns an IFile with file encoding set to UTF-8.

If I drag and drop (or copy/paste) my resource into a folder of Local Files (Local System Type), and the resource contains at least one double byte UTF-8 character (e.g. "ä") the operation works but ends with the error message:

Operation failed. File system input or output error.
(Details:) Message reported from file system: Local upload: file size mismatch for MYFILE.txt

This is especially bad when attempting to copy several files, because the operation is being canceled after the first (successful) transfer.

I've debugged it and this is what I think happens:

  • FileServiceSubSystem correctly calls LocalFileService#upload(...) (srcEncoding is UTF-8, rmtEncoding is Cp1252).
  • LocalFileService#upload(...) correctly transfers the file.
  • LocalFileService(753) checks whether the transferred file's byte size is equal to the source file's byte size. This causes the exception, since the source UTF-8 file has more bytes than the target Cp1252 file.
  • I think the error lies in line LocalFileService(752) which should set boolean sizeCheck to false, since it's supposed to compare the source and target file code pages (which are different here), but what it does is comparing hostEncoding (Cp1252) with SystemEncodingUtil.getInstance().getEnvironmentEncoding() (Cp1252) instead of srcEncoding.

I've attached a screenshot of the suspicious code lines.

Thanks!

LocalFileService.PNG

LocalFileService.PNG