eclipse-platform / eclipse-platform/eclipse.platform

Moving a file inside of an operation: moved File's Charset is only available after the operation

Open
#575 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
165
Forks
174
Avg merge
2d 8h
Merged PRs (30d)
22

Description

When scheduling a job using IWorkspace#run that moves a file, I instantly want to be able to manipulate the file inside of the job.
This is not currently possible due to charset information only being updated after the Job was ran.

### Under the Hood
Move uses the Java-Internal File-rename operation, which internally calls a FS-move.
As part of [Workspace#endOperation](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java#L1552), all listeners are notified of the file move-event.
The workspace-own [CharsetManager](https://github.com/eclipse-platform/eclipse.platform/blob/master/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java) implements it's own [ResourceChangeListener](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java#L148) which is [notified](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java#L300) by the [NotificationManager](https://github.com/eclipse-platform/eclipse.platform/blob/master/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java#L300)

### Proceeding
There are two conflicting behaviors/expectations:
1. Updates of charset settings due to the movement of a resource are processed through the CharsetManager after the workspace operation has been completed. Any changes on the resource within the operation will not see its proper charset.
2. Changes to the resource within the operation expect the proper charset to be available for the resource.

Currently, the implementation accepts that 2. is not fulfilled. To achieve 2. the charset of a resource has to be updated just-in-time after a movement/copy during a workspace operation. This would, however, require a change of 1. since charsets cannot be updated asynchronously after a workspace operation completed.

There are two options to proceed:
1. Ensure that charset settings are updated just-in-time. This may require larger changes and have unpredictable side effects.
2. Accept the current behavior and remove the test or change it to expect the "faulty" charset during the workspace operation so that it documents the acceptance of the current behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.