How to manage files with `admin://` protocol?

I am trying to copy/move files with Gio.File. I can move files with following code using paths

from gi.repository import Gio
src = Gio.File.new_for_path('a')
dst = Gio.File.new_for_path('b')
src.move(dst, Gio.FileCopyFlags.NONE)

It works fine. But as soon as I try something like following

from gi.repository import Gio
src = Gio.File.new_for_path('a')
dst = Gio.File.new_for_uri('admin:///b')
src.move(dst, Gio.FileCopyFlags.NONE)

It doesn’t work anymore. It gives following error

gi.repository.GLib.GError: g-io-error-quark: Operation not supported (15)

I also tried read(), open_readwrite(), etc. functions, they all give above error or ‘Not mounted (16)’ error if file(s) are created using Gio.File.new_for_uri() constructor.

What is the way to do it?

Call mount_enclosing_volume() , then perform the move operation from the callback after mount_enclosing_mount_finish() returned successfully.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.