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

Exporting and then opening a .grist file doesn't work correctly #4

Open
ruudschouten opened this issue Apr 7, 2023 · 9 comments
Open
Labels
bug Something isn't working

Comments

@ruudschouten
Copy link

Currently on version 0.2.1, and wanted to export a newly created document.

Exporting is done by opening the document, clicking Share > Download.

If I then try to import this exported .grist file, I get a warning popup which says:

Import failed: File format is not supported.

If I instead double click the .grist file to open Grist automatically with this file, I get a different error:

Error accessing document
You can try reloading the document, or using recovery mode. Recovery mode opens the document to be fully accessible to owners, and inaccessible to others. It also disables formulas. [SQLITE_CANTOPEN: unable to open database file]

Trying to enter recovery mode will show a toast message in the lower left stating

14:01:20 SQLITE_CANTOPEN: unable to open database file.

This also has a nice Report button, but when I click this I get another toast message, saying the report form isn't set up.

@paulfitz
Copy link
Member

paulfitz commented Apr 7, 2023

Thanks for reporting this @ruudschouten, will look into it. Which OS was this? In the meantime, you should be able to find Grist documents sitting on your filesystem as .grist files.

@paulfitz paulfitz added the bug Something isn't working label Apr 7, 2023
@ruudschouten
Copy link
Author

This was on Windows 10; Version 10.0.19045 Build 19045

@nasmi3
Copy link

nasmi3 commented Apr 12, 2023

Hi,
I saw the same issue on windows. Grist is able to open any .grist file created by making a new doc through the app. However it doesn't work when :

  • I make a copy of the .grist file, rename it and try to open it
  • Try to open a .grist file created and downloaded a server instance of grist (grist-core)

It might be linked with the fact that the documents have colliding or absent document id in the sqlite (like the home.sqlite for grist-core)

@paulfitz
Copy link
Member

@nasmi3 are you also using Windows?

@nasmi3
Copy link

nasmi3 commented Apr 12, 2023 via email

@ianzhuo
Copy link

ianzhuo commented Apr 13, 2023

Hi, I saw the same issue on windows. Grist is able to open any .grist file created by making a new doc through the app. However it doesn't work when :

  • I make a copy of the .grist file, rename it and try to open it
  • Try to open a .grist file created and downloaded a server instance of grist (grist-core)

It might be linked with the fact that the documents have colliding or absent document id in the sqlite (like the home.sqlite for grist-core)

Hi, I I tried to roll back to grist-electron-windows-0.1.8-x64.exe, and then the file opening function back to normal.

@Anamon
Copy link

Anamon commented Nov 12, 2023

This persists in version 1.1.3.

There seems to be some internal (to the .grist file) or external source which keeps a record of a .grist file's absolute path and filename. It needs to stay absolutely the same, otherwise it can't be opened anymore.

Reproduction steps

  1. Create a new file in the app, note the location of the .grist file in the user's directory.
  2. Close grist-electron.
  3. Change some letter in the filename of the .grist file.
  4. Try to open the .grist file in grist-electron.
  5. Close grist-electron.
  6. Change the name of the .grist file back to the original name.
  7. Open the .grist file again in grist-electron.

In step 4, you will get the SQLITE_CANTOPEN error when trying to open the file. In step 7, after restoring the original filename, the file opens properly again. So there is obviously nothing wrong with the file itself (other applications can also open it as an SQLite3 file without issues).

On a quick check, I couldn't find a reference to the filename in the .grist file, nor the grist-electron application data directory, though. So I'm not sure where grist-electron is getting the information on what the file has to be called.

@paulfitz
Copy link
Member

Hi @Anamon, the interaction between the Electron version of Grist and the file system is super primitive:

// Here is our dumb strategy for opening random Grist files on the
// file system: just mint a key and soft-link to them. If being
// professional, Grist should be watching for external modifications.
// Baby steps though.
let docId: string|undefined;
let maybeDocId: string|undefined;
if (!path.relative(root, target).startsWith('..')) {
const did = path.basename(target, '.grist');
const p = path.join(docsRoot, `${did}.grist`);
if (await this.normalizePath(p) === target) {
maybeDocId = did;
}
}

Basically, it is using a simple hack to adapt the server version of Grist (which has full control of where files are stored) to the desktop. The server version expects to have a little entry for each file in a database, so we make one to keep it happy. This could definitely be improved!

@jyio
Copy link

jyio commented Feb 11, 2024

Greetings. I'm seeing similar behavior in release 0.2.8 on Windows 10 when attempting to open a *.grist file from the filesystem,

Error accessing document
You can try reloading the document, or using recovery mode. Recovery mode opens the document to be fully accessible to owners, and inaccessible to others. It also disables formulas. [SQLITE_CANTOPEN: unable to open database file]

It could import the very same file just fine, but of course that results in a new file in %USERPROFILE%\Documents. Now, this file could be opened without error, but a different file copied into %USERPROFILE%\Documents triggers SQLITE_CANTOPEN.

Grist serves me just fine in headless mode, so this is not a deal-breaker for me; but this could make it more difficult to sell Grist to folks who could not set up their own server but still require assurance that they could access their data for years to come (even if the cloud services went offline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants