pi-ext bugabingas pi extensions
owned by admin
README Source History Refs Compare Notes Search fix: fall back to exclusive create when hard links are unsupported 2a01b347e969186992fc2c9989a2643f8cf5a5e4
Oliver Jan Krylow <oliver@bugabinga.net > · 25 Sep 2026
SSH signature · not checked
Browse files Compare with HEAD
Android SELinux denies link() to app domains, breaking gj startup
migration and bak restore with EACCES. Keep hard links where supported
and fall back to O_EXCL writes on EACCES, EPERM, ENOSYS, EOPNOTSUPP,
EXDEV, and EMLINK. EEXIST duplicate semantics are unchanged.
Changed files (2) extensions/bak/archive.ts Modified 305 + function isLinkUnsupported (error
: unknown )
: boolean {
306 + if (
! (error
instanceof Error && "code" in error))
return false ;
307 + const { code }
= error
as NodeJS .
ErrnoException ;
309 + code
=== "EACCES" || 310 + code
=== "EPERM" || 311 + code
=== "ENOSYS" || 312 + code
=== "EOPNOTSUPP" || 313 + code
=== "EXDEV" || 318 + async function exclusiveWrite (
321 + )
: Promise <
boolean > {
323 + await writeFile (path, body, { mode:
0o600 , flag:
"wx" });
326 + if ((error
as NodeJS .
ErrnoException ).
code === "EEXIST" )
return false ;
305 331 async function publishNoReplace (
307 333 body
: Uint8Array ,
319 345 }
catch (error) {
320 346 if ((error
as NodeJS .
ErrnoException ).
code === "EEXIST" )
return false ;
348 + if (
! isLinkUnsupported (error))
throw error;
349 + return exclusiveWrite (path, body);
324 352 await unlink (temporary).
catch (()
=> undefined );
extensions/good-job/storage.ts Modified 180 + function isLinkUnsupported (error
: unknown )
: boolean {
181 + if (
! isNodeError (error))
return false ;
183 + error.
code === "EACCES" || 184 + error.
code === "EPERM" || 185 + error.
code === "ENOSYS" || 186 + error.
code === "EOPNOTSUPP" || 187 + error.
code === "EXDEV" || 188 + error.
code === "EMLINK" 192 + async function exclusiveCreateJson (
196 + const file
= await open (target,
"wx" ,
0o600 );
198 + await file.
writeFile (
`${ JSON . stringify (value)}\n` ,
"utf8" );
201 + await file.
close ();
180 205 export async function atomicCreateJson (
183 208 )
: Promise <
void > {
184 209 const temporary
= await temporaryJson (target, value);
186 - await link (temporary, target);
212 + await link (temporary, target);
215 + if (
! isLinkUnsupported (error))
throw error;
216 + await exclusiveCreateJson (target, value);
187 218 await rm (temporary, { force:
true });
188 219 await syncDirectory (
dirname (target));
189 220 }
catch (error) {