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

Writing neighboring files #997

Open
Mikenux opened this issue Apr 3, 2023 · 11 comments
Open

Writing neighboring files #997

Mikenux opened this issue Apr 3, 2023 · 11 comments
Labels
help wanted new api This requires adding API to an existing portal portal: documents Issues with the documents portal

Comments

@Mikenux
Copy link

Mikenux commented Apr 3, 2023

This is the equivalent of #463, but for writing files.

To be exact, it is about writing/creating folders or files after the opening or creation of a folder or file.

There are already 4 app cases listed:

  • Firefox, saving a webpage. An html file is saved (e.g. site.html) and Firefox automatically saves several files in a folder with the same name as the html file with a suffix (e.g. site_files). The html file and its companion folder are saved in the same folder.
  • Inform. It creates a .materials folder (folder extension) with the same name and in the same folder as an open .inform folder. It also creates folders and files in the .inform project folder after creating it.
  • Metadata Cleaner. Its developer wants to save copies of open files (to keep the originals) in their respective parent folders. Filenames should be the same as the originals but with a suffix (for example, filename.cleaned.ext, where ext is the extension of the original file).
  • KiCad7. It asks for a project name when creating a project. This creates a folder with the name of the project, and in it files with the same name but with the extensions .kicad_pro, .kicad_pcb and .kicad_sch.

Cases, said another way:

  • Save a file, then write a folder with multiple files in the same folder. The saved file and the written folder (partially) share the same name.
  • Save/create a folder, then write other folders and/or files in it. They share (in part) or not the same name.
  • Open a folder with extension, then create another folder with the same name but different extension in the same directory.
  • Open files, then write files sharing the same name with a suffix and the same extension. Files can come from different locations.

Other cases are welcome. If they are different from those mentioned, please provide a description if possible.

Addition (June 18, 2023)

Other cases :

  • IDEs must write files that are built in a project folder or a specific folder.
  • Inform wants to create the .materials folder if it does not exist after opening the .inform folder.
@GeorgesStavracas GeorgesStavracas added the new api This requires adding API to an existing portal label Apr 23, 2023
@Mikenux
Copy link
Author

Mikenux commented Jun 13, 2023

For creating and saving multiple files:

  • Case Examples: Inform and KiCad which create default files and folders when creating a project, Firefox which saves several files and folders.
  • The number of files to be created or saved and their sizes, including those of folders, are displayed in the file chooser. A list with the details must be accessible.
  • The project or website name is named without any extension.
  • Note: The information must be accurate regarding the files and folders that will be created or saved (including saved from the Internet).
  • Sample UI: SaveMultipleFiles

Feasible? Opinions?

@ctlcltd
Copy link

ctlcltd commented Jun 13, 2023

Interesting, but I don't think it's feasible. Usually the file chooser returns a location. As things stand, I don't think it's possible to pass much information. Such a mechanism involve the system api rather than the UI, would this mean modifying every existing file chooser? A few days ago I was seeing Gtk file chooser, I don't know if there are hooks to do this or make it possible with portals api.

@Mikenux
Copy link
Author

Mikenux commented Jun 14, 2023

I don't know because I'm not a developer. But this will certainly involve modifying the way file choosers work.

@Marukesu
Copy link
Contributor

There's already the SaveFiles method in the FileChooser portal, the application send the list of files it want written and the portal will return the ones that got actually written.

@Mikenux
Copy link
Author

Mikenux commented Jun 22, 2023

@Marukesu: Indeed, but does it work by also creating folders? Also, the phrasing in the documentation leads me to think that the files are saved as is, with no option to change the name. Also, is file size taken into account?

Another question: What about the Firefox case? Are the relevant files of the website to save already downloaded or downloaded after saving the html file?

@Marukesu
Copy link
Contributor

@Marukesu: Indeed, but does it work by also creating folders?

no, all the paths used will be exported to the sandbox as files.

Also, the phrasing in the documentation leads me to think that the files are saved as is, with no option to change the name.

yes, it's intended. if we are dealing with auxiliary files, like all the use cases said does, allowing to change the name won't be helpful.

Also, is file size taken into account?

no. why it would, the chooser is to select a location.

Another question: What about the Firefox case? Are the relevant files of the website to save already downloaded or downloaded after saving the html file?

i don't get it, the firefox case seem simple:

  • firefox ask the user a name to save the site with.
  • a SaveFiles call with [ 'site.html', 'site_files/file.txt', ... ] will return paths that can be used to write the contents.
  • firefox write the files.

keep in mind that the portal doesn't save (or in the case of OpenFile, open) anything. it just return paths that can be used by the application, how and in what order things are written is up to the application.

@Marukesu
Copy link
Contributor

expanding in the user cases:

  • Inform and Metadata Cleaner are Portal to open file and neighbouring files #463 use cases, they want access to a path that came from a opened one.
  • kicad case is similar to the firefox, a SaveFiles call with [ 'project-name/project-name.kicad_pro', 'project-name/project-name.kicad_pcb', 'project-name/project-name.kicad_sch' ] in the files option.

@Mikenux
Copy link
Author

Mikenux commented Jun 23, 2023

Although Inform and Metadata Cleaner are cases related to opening files/folders, I thought it was a good idea to address them separately so that #463 just focuses on the opening part, because the rest is about writing files. Note that I have not discussed these cases yet.

The first part offered is just when creating a project that also writes other files (KiCad) or an app that saves multiple files (Firefox). The goal is for the user to be aware of an app's writing activity (here: that other files are being written, which ones and how much storage space they take). This obviously requires extending the portal and file choosers.

@ctlcltd
Copy link

ctlcltd commented Jun 23, 2023

In my case the multiple files are saved on folder, but only the first file gets the right name, the other files get hashed file name, eg.

  1. bouquet-right-filename.ext
  2. -x--pf658akj.ext
  3. --e-sfqxad-7.ext

Files are saved but are unrecognizable, except the first one that is saved. This was a month ago in Arch Linux, with xdg-desktop-portal-gtk, file chooser Gtk3, Qt6. Opening files from folder works as expected.

@Marukesu
Copy link
Contributor

Although Inform and Metadata Cleaner are cases related to opening files/folders, I thought it was a good idea to address them separately so that #463 just focuses on the opening part, because the rest is about writing files. Note that I have not discussed these cases yet.

Unless the user set the chooser to "open in read-only mode" (availability depends of the backend), if you open a path you can already write to it. so any case that deals with "give access to a neighbour path based in a opened path" is a #463 case solely.

This issue only make sense if you are talking about "also create theses others files when creating this file".

The first part offered is just when creating a project that also writes other files (KiCad) or an app that saves multiple files (Firefox). The goal is for the user to be aware of an app's writing activity (here: that other files are being written, which ones and how much storage space they take). This obviously requires extending the portal and file choosers.

You can show the file names sent in the SaveFiles call already, that just need implementation changes in the backends to use that information.

The file size doesn't make sense at all with how the portal (or even any chooser API) works. Even if a option to send the file sizes is added, i don't think it will be used by libraries.

In my case the multiple files are saved on folder, but only the first file gets the right name, the other files get hashed file name, eg.

  1. bouquet-right-filename.ext
  2. -x--pf658akj.ext
  3. --e-sfqxad-7.ext

Files are saved but are unrecognizable, except the first one that is saved. This was a month ago in Arch Linux, with xdg-desktop-portal-gtk, file chooser Gtk3, Qt6. Opening files from folder works as expected.

AFAIK, none of the more common libraries make use of the SaveFiles method, so a application will need to talk to the portal directly, or update the used library to make use of it.

@GeorgesStavracas GeorgesStavracas moved this to Needs Triage in Triage Oct 2, 2023
@GeorgesStavracas GeorgesStavracas added help wanted portal: documents Issues with the documents portal labels Oct 3, 2023
@GeorgesStavracas GeorgesStavracas moved this from Needs Triage to Triaged in Triage Oct 3, 2023
@Mikenux
Copy link
Author

Mikenux commented Jan 10, 2024

@Marukesu:

Thanks!

For me, neighbor files are additional files to open (I made proposals for this which are now in the Discussions tab), and not provide access to the parent directory. But even if it would be to give access to the parent directory, in the case of Metadata Cleaner it is better to have something specific, rather than having access to the parent directory of each file (because the files can come from different locations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted new api This requires adding API to an existing portal portal: documents Issues with the documents portal
Projects
Status: Triaged
Development

No branches or pull requests

4 participants