You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminating typst may leave package cache in broken state #5935
If the typst process is terminated while it's unpacking a package, it will leave it in a half-extracted state and any future usage of the package may be broken.
Yes, but in the end, both instance would have to put the downloaded package into the same directory. Actually, I think on Unix it should be fine, since mv is an atomic operation and the files are only read and not written to. So if one instance will mv the exact same package directory to the target directory, replacing another one (package directory) would basically be a no-op. But I'm not sure that this is the case with all OSes/FSes.
Another possibility for this issue would be to keep an index of hashes. This would also allow detection of corruption due to e.g. faulty disks or sudden network disconnects.
Cryptography rambling
That would suffice to ensure integrity (contents haven't been modified since hashed).
Theoretically we could also go one step further and also ensure authenticity via signing. The workflow for that could look like a set of ed25519 pubkeys in the repo, each package author has to submit theirs and sign each package addition/update with their key. The signature could be stored alongside the package.
Advantages: Authenticity, hash index replaced by less often updated key index, could decentralize package index to instead fetch from author repos at a later point.
Disadvantages: The key index still has to be updated, cryptography is difficult and it's likely to be at least somewhere minimally wrong → more attack surface.
The hashes are nice, but Typst is not Nix, and usually checksum is checked manually, so this can be somewhat possible in the future, but I don't think it's necessary. If anything, an author absolutely can add some integrity/authenticity files in the package for anyone to check that, but adding this to the CLI at least now is definitely overkill. And mandating any of that from the authors is definitely a bad experience, as most people don't care, or it will be bothersome, and some might not even know about this (and how it works).
Activity
laurmaedje commentedon Feb 23, 2025
Maybe we could download into a temporary directory and atomically move into the package cache, if it's not already there? That might also fix #2739.
MultisampledNight commentedon Feb 23, 2025
It'd fix #2739 iff a different temporary directory is chosen for each Typst instance (i.e
mktemp -dshould suffice I think).Andrew15-5 commentedon Feb 23, 2025
Yes, but in the end, both instance would have to put the downloaded package into the same directory. Actually, I think on Unix it should be fine, since
mvis an atomic operation and the files are only read and not written to. So if one instance will mv the exact same package directory to the target directory, replacing another one (package directory) would basically be a no-op. But I'm not sure that this is the case with all OSes/FSes.MultisampledNight commentedon Feb 23, 2025
Another possibility for this issue would be to keep an index of hashes. This would also allow detection of corruption due to e.g. faulty disks or sudden network disconnects.
Cryptography rambling
That would suffice to ensure integrity (contents haven't been modified since hashed).
Theoretically we could also go one step further and also ensure authenticity via signing. The workflow for that could look like a set of ed25519 pubkeys in the repo, each package author has to submit theirs and sign each package addition/update with their key. The signature could be stored alongside the package.
Advantages: Authenticity, hash index replaced by less often updated key index, could decentralize package index to instead fetch from author repos at a later point.
Disadvantages: The key index still has to be updated, cryptography is difficult and it's likely to be at least somewhere minimally wrong → more attack surface.
Andrew15-5 commentedon Feb 23, 2025
The hashes are nice, but Typst is not Nix, and usually checksum is checked manually, so this can be somewhat possible in the future, but I don't think it's necessary. If anything, an author absolutely can add some integrity/authenticity files in the package for anyone to check that, but adding this to the CLI at least now is definitely overkill. And mandating any of that from the authors is definitely a bad experience, as most people don't care, or it will be bothersome, and some might not even know about this (and how it works).
istudyatuni commentedon Feb 25, 2025
I think this is bad because tmp directory could be on another drive, so it's better to store downloads alongside main cache