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

gui: fix media eject on linux (#4700) #4701

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

buzzhuzz
Copy link
Contributor

Removable media is not ejected on linux platform

Make get_removable_drive_from_path() check if path is a dir or not. Trim last component in latter case only.

Removable media is not ejected on linux platform

Make get_removable_drive_from_path() check if path is a dir or not.
Trim last component in latter case only.
@discip
Copy link
Contributor

discip commented Mar 25, 2024

THANK YOU!   Finally! 😃👍🏻

@cochcoder
Copy link
Contributor

Thank you so much!

@discip
Copy link
Contributor

discip commented Mar 25, 2024

After testing this commit I discovered that this PR unfortunately doesn't resolve #4700, as the removable drive doesn't get unmounted.

@buzzhuzz
Copy link
Contributor Author

That is may be related to permissions and volumes handling on different machines.

@discip, could you please collect some logs?

  1. Run log collection
tail -f /var/log/syslog | grep -i mount
  1. Check if you can unmount the volume using 'umount' manually:
    umount /media/<username>/<storage>
  2. Try unmount using Orca

I have a next output while exporting G-code to a removable media following by ejection of the storage:

2024-03-26T03:21:56.023070+05:00 db360 udisksd[1011]: Mounted /dev/sda1 at /media/dbuzdyk/AB3D-77C7 on behalf of uid 1000
2024-03-26T03:21:56.024726+05:00 db360 kernel: [57414.481995] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
2024-03-26T03:22:00.588744+05:00 db360 systemd[1]: media-dbuzdyk-AB3D\x2d77C7.mount: Deactivated successfully.
2024-03-26T03:22:00.603814+05:00 db360 udisksd[1011]: Cleaning up mount point /media/dbuzdyk/AB3D-77C7 (device 8:1 is not mounted)
2024-03-26T03:22:00.608714+05:00 db360 udisksd[1011]: Unmounted /dev/sda1 on behalf of uid 1000

@discip
Copy link
Contributor

discip commented Mar 26, 2024

@buzzhuzz

First of all:

Thank you for the almost instant reaction! 👍🏻

Unfortunately I'm not on my Linux (Manjaro) machine right now, so I won't be able to test this until later.

  1. Do I need to put this straight into the terminal?

    1. tail -f /var/log/syslog | grep -i mount
      
    2. How do I disable it afterwards?
  2. I don't know if this is related, but I am also seeing the popup mentioned in the following comment on every single start of OrcaSlicer:
    Various fix & improvements to collapse sidebar #3044 (comment)

@buzzhuzz
Copy link
Contributor Author

buzzhuzz commented Mar 26, 2024

@discip

I've took a brief look into Manjaro removable drive handling and found it is different to one on debian/ubuntu systems I am used to.

Could you provide additional details about your distribution (like desktop environment used), so I would install it onto my test machine for debugging?

@discip
Copy link
Contributor

discip commented Mar 26, 2024

Yeah, for sure!

It's Manjaro GNOME (x86_64).

@buzzhuzz
Copy link
Contributor Author

buzzhuzz commented Mar 27, 2024

@discip

Unfortunately I can't reproduce issue using fresh install of Manjaro GNOME: all works exactly the same as on my Ubuntu machine despite mount points for removable media moved from /media/<username>/ to /run/media/<username>/.

So I've added extensive logging on debug branch https://github.com/buzzhuzz/OrcaSlicer/tree/dbuzz/debug-orca-pr4701

Could you get debug build at https://github.com/buzzhuzz/OrcaSlicer/actions/runs/8444658594 and give it a try?
Just run it from terminal like this:

$ ./OrcaSlicer_Linux_V2.0.0-rc.AppImage | tee debug-pr4701.log

Slice some object, save gcode to USB drive/SD card, press eject media, wait few seconds and close Orca.

All necessary logs will be collected into debug-pr4701.log within current directory.

@discip
Copy link
Contributor

discip commented Mar 27, 2024

Could you get debug build at https://github.com/buzzhuzz/OrcaSlicer/actions/runs/8444658594 and give it a try?

Will do when I'm home again.

Copy link
Owner

@SoftFever SoftFever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good
Thank you

@discip
Copy link
Contributor

discip commented Mar 27, 2024

@SoftFever
Please let me test before merging.
Will do in the next hour.

@SoftFever
Copy link
Owner

no issues.
Take your time

@discip
Copy link
Contributor

discip commented Mar 27, 2024

@buzzhuzz

Unfortunately this did't work either. 😞

debug-pr4701.log.txt

@buzzhuzz
Copy link
Contributor Author

@discip

Assuming that you have redacted log replacing your username with the namethe log actually looking good. I see removable media actually detected by the slicer and Orca tries to unmount it calling umount /run/media/name/PARTS:

eject_drive:323 | umount /run/media/name/PARTS

Could you do more tests on the same build?

  1. Run Orca, slice model, save it to the removable drive, do not eject the drive
  2. run in the terminal:
    mount | grep PARTS
    
    You shall see the entry for /run/media/name/PARTS
  3. Eject drive within Orca
  4. run in the terminal
    mount | grep PARTS
    
    In a good case you have /run/media/name/PARTS disappeared.
  5. If /run/media/name/PARTS is still mounted, try to call unmount it manually:
    umount /var/media/name/PARTS
    
    And check if is still there or not. May be umount print some logs into the terminal giving additional clues.

@discip
Copy link
Contributor

discip commented Mar 27, 2024

@buzzhuzz

Everything you predicted works as apparently intended, but I can still access the drive via Nautilus:

image

However if I click the eject symbol, the removable drive disappears. This also works if I use the eject symbol in the taskbar:

image

And in both cases this popup confirms the success of ejecting the drive:

image

@buzzhuzz
Copy link
Contributor Author

So good news in this PR is actually working.

It looks like some bug or non-consistent behavior within Nautilus.

I've just checked on my system and I see the same behavior: drive is listed by Nautilus on side panel even though system log says it is no longer mounted in the system. Never noticed that previously, probably because I rarely use nautilus.

@discip
Copy link
Contributor

discip commented Mar 28, 2024

  1. So, does the drive get mounted again as soon as it is accessed via Nautilus?

  2. So good news in this PR is actually working.

    That means: It should be safe to remove the drive, after ejecting it in Orca Slicer, while it's still listed in Nautilus, right?

@buzzhuzz
Copy link
Contributor Author

@discip

So, does the drive get mounted again as soon as it is accessed via Nautilus?

Yes

That means: It should be safe to remove the drive, after ejecting it in Orca Slicer, while it's still listed in Nautilus, right?

Correct

You could check what happens with the drive by display system-wide log:

sudo journalctl -xe

With that running in a display corner, run test sequence involving both Orca and Nautilus.

@discip
Copy link
Contributor

discip commented Mar 28, 2024

@SoftFever

This is good to go! 😊

@SoftFever
Copy link
Owner

@buzzhuzz Thank you for the fix and patience.

@discip thanks for testing it.

Merged

@SoftFever SoftFever merged commit 45ef4ae into SoftFever:main Mar 29, 2024
12 checks passed
@buzzhuzz buzzhuzz deleted the dbuzz/fix-media-eject branch March 29, 2024 06:14
SoftFever pushed a commit that referenced this pull request Apr 13, 2024
* gui: fix media eject on linux (#4700)

Removable media is not ejected on linux platform

Make get_removable_drive_from_path() check if path is a dir or not.
Trim last component in latter case only.

* Revert unnecessary style changes
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.

4 participants