Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update file permissions when returning from shell #1213

Closed
wants to merge 3 commits into from

Conversation

bluesuncat
Copy link

Fixes #1172

@bluesuncat
Copy link
Author

Not sure why, but running app.ui.loadFile(app, true) here will not refresh the file information for the currently selected file, but selecting a different file and going back to the first one, will update the correct information.

This commit adds the same code that is executed when the user manually runs the reload command, but for some reason it does not behave the same way. Im a bit clueless as to why.

app.ui is not yet loaded at this point
When returning from the shell, the file information that will be printed in the prompt are no longer valid, so we need to reload them.
@bluesuncat
Copy link
Author

Ok, I think I got this fixed.

This will now refresh the file information during the "draw" function before executing ui.drawPromptLine(nav)

With this the file stats (like permissions) for the currently selected file are updated to reflect possible changed made on the shell (inside lf, e.g. by pressing w)

While this seems to work, I cannot say with confidence that I understand most of the things lf does in these functions, so there may be a better way to implement this. A closer review of this and possible side effects would be advised.

@gokcehan
Copy link
Owner

@bluesuncat I don't think it is a good idea to reload every time a shell command is used as it can be a heavy operation sometimes. Instead, you could selectively run reload in relevant custom commands if you don't like manual reloads for such occasions. For example, a reloading chmod can be defined as follows:

cmd chmod %{{
    chmod $1 $f
    lf -remote "send $id reload"
}}

@bluesuncat
Copy link
Author

bluesuncat commented Apr 30, 2023

@bluesuncat I don't think it is a good idea to reload every time a shell command is used as it can be a heavy operation sometimes.

At the moment, the reload is only executed when returning from an interactive shell.
Using shell commands using : wont trigger the reload (but probably need the same fix)

However, I still think that there is another issue and a better fix here.

While this patch would reflect permission changes, changes like adding/deleting files seems to be ignored only for the current pane.

To demonstrate:

a

Now I press 'w' to get a shell and run 'rm -rf ../* to delete all files starting with the parent directory. Then I exit the shell to return to lf in this state:
b

As mentioned, I don't quite get how this works, but there obviously is a function that updated to parent and child pane of the current path to reflect file changes but the current path is unaffected. I assume this is a bug on its own and for the current path the "updatefilechanges" function is missing. But since it works without a reload, this is where the changes in file permission could probably also be fixed.

@bluesuncat
Copy link
Author

There is a better and more complete solution to be found (hopefully)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File permission changes are not reloaded when using period
2 participants