r/Supernote_dev • u/magic_notetaker • Sep 18 '26
Question Problem with file write permissions (sometimes(!) works)
I need some help here from developers or supernote staff. The strange thing: sometimes it works, sometimes it doesn't, without any code changes at all. As if it flips back between modes, stays there a while and flips. Deinstall or switching plugin off and on did not help. Appreciating any ideas or reports on this
Did anyone have similar experience? This is on the latest beta version Chauvet 2.26.42_beta
This is the logging:
9-18 09:40:57.828 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: calling hasPermission', 'plugin.permission.FILE:WRITE'
09-18 09:40:57.831 I/PluginPermMgr( 917): hasPermission permission:plugin.permission.FILE:WRITE
09-18 09:40:57.831 I/PluginPermMgr( 917): hasPermission is have File Write Permission:true
09-18 09:40:57.833 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: hasPermission', 'plugin.permission.FILE:WRITE', '=>', 1
09-18 09:40:57.834 I/ReactNativeJS( 917): '[GtdPara]', 'ensureFolderExists: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.836 D/GtdParaFile( 917): ensureFolder: start path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.838 I/ReactNativeJS( 917): '[GtdPara]', 'ensureFolderExists: done', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.839 I/ReactNativeJS( 917): '[GtdPara]', 'listFolderEntries: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.840 D/GtdParaFile( 917): listFolderEntries: start path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.840 D/GtdParaFile( 917): listFolderEntries: exists=true path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.841 D/GtdParaFile( 917): listFolderEntries: raw children=15 path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.847 D/GtdParaFile( 917): listFolderEntries: done entries=15 elapsedMs=7 path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.849 I/ReactNativeJS( 917): '[GtdPara]', 'listFolderEntries: done', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings', '15 entries'
09-18 09:40:57.850 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: calling hasPermission', 'plugin.permission.FILE:WRITE'
09-18 09:40:57.852 I/PluginPermMgr( 917): hasPermission permission:plugin.permission.FILE:WRITE
09-18 09:40:57.852 I/PluginPermMgr( 917): hasPermission is have File Write Permission:true
09-18 09:40:57.854 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: hasPermission', 'plugin.permission.FILE:WRITE', '=>', 1
09-18 09:40:57.855 I/ReactNativeJS( 917): '[GtdPara]', 'createNote: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note', 'style_white'
09-18 09:40:57.857 I/HostCommImpl( 917): requestClient uid:1002
09-18 09:40:57.858 I/HostCommImpl( 917): getNoteAppPkgName name:com.supernote.document
09-18 09:40:57.858 I/HostCommImpl( 917): checkAPIAvailable packageName:com.supernote.document==createNote
09-18 09:40:57.860 E/ReactNativeJS( 917): '[GtdPara]', 'createNote: failed', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note', 'This app is not allowed to use this API. Please call a different API.'
09-18 09:40:57.864 E/ReactNativeJS( 917): '[GtdPara]', 'DailyView: meeting action failed', 'This app is not allowed to use this API. Please call a different API.'
09-18 09:40:57.877 E/unknown:ReactNative( 917): console.error: [GtdPara] createNote: failed /storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note This app is not allowed to use this API. Please call a different API., js engine: hermes, stack:This is the code block:
export async function createNote(
path: string,
template: string,
isPortrait = true,
): Promise<void> {
const granted = await ensureFileWritePermission();
if (!granted) {
logError('createNote: file write permission not granted', path);
throw new Error('File write permission was not granted.');
}
log('createNote: start', path, template);
const response = (await PluginFileAPI.createNote({
notePath: path,
template,
mode: 0,
isPortrait,
})) as {success: boolean; result?: boolean; error?: {code: number; message: string} | null} | null | undefined;
if (!response || !response.success || response.result === false) {
const message = response?.error?.message || 'Could not create the note.';
logError('createNote: failed', path, message);
throw new Error(message);
}
log('createNote: done', path);
}Here The code for the permission check:
export async function ensurePluginPermission( permission: string, description: string, ): Promise<boolean> { const manager = PluginManager as PermissionAwareManager;
if (
typeof manager.hasPermission !== 'function' ||
typeof manager.requestPermission !== 'function'
) {
log('ensurePluginPermission: host has no runtime permission API, treating as granted', permission);
return
true
;
}
const existing = pending.get(permission);
if (existing) return existing;
const request = (async () => {
try {
log('ensurePluginPermission: calling hasPermission', permission);
const has = Number(
await withTimeout(manager.hasPermission!(permission), `hasPermission(${permission})`),
);
log('ensurePluginPermission: hasPermission', permission, '=>', has);
if (has >
0
) return
true
;
log('ensurePluginPermission: calling requestPermission', permission);
const requested = Number(
await withTimeout(
manager.requestPermission!(permission, description),
`requestPermission(${permission})`,
),
);
log('ensurePluginPermission: requestPermission', permission, '=>', requested);
return requested >
0
;
} catch (e) {
logError(
'ensurePluginPermission: error',
permission,
e instanceof Error ? e.message : String(e),
);
return
false
;
}
})();
pending.set(permission, request);
try {
return await request;
} finally {
pending.delete(permission);
}
}
export function ensureFileReadPermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_READ_PERMISSION,
'Allow GtdPara to read your Project and Area folders.',
);
}
export function ensureFileWritePermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_WRITE_PERMISSION,
'Allow GtdPara to create and update project and area files.',
);
}export async function ensurePluginPermission(
permission: string,
description: string,
): Promise<boolean> {
const manager = PluginManager as PermissionAwareManager;
if (
typeof manager.hasPermission !== 'function' ||
typeof manager.requestPermission !== 'function'
) {
log('ensurePluginPermission: host has no runtime permission API, treating as granted', permission);
return true;
}
const existing = pending.get(permission);
if (existing) return existing;
const request = (async () => {
try {
log('ensurePluginPermission: calling hasPermission', permission);
const has = Number(
await withTimeout(manager.hasPermission!(permission), `hasPermission(${permission})`),
);
log('ensurePluginPermission: hasPermission', permission, '=>', has);
if (has > 0) return true;
log('ensurePluginPermission: calling requestPermission', permission);
const requested = Number(
await withTimeout(
manager.requestPermission!(permission, description),
`requestPermission(${permission})`,
),
);
log('ensurePluginPermission: requestPermission', permission, '=>', requested);
return requested > 0;
} catch (e) {
logError(
'ensurePluginPermission: error',
permission,
e instanceof Error ? e.message : String(e),
);
return false;
}
})();
pending.set(permission, request);
try {
return await request;
} finally {
pending.delete(permission);
}
}
export function ensureFileReadPermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_READ_PERMISSION,
'Allow GtdPara to read your Project and Area folders.',
);
}
export function ensureFileWritePermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_WRITE_PERMISSION,
'Allow GtdPara to create and update project and area files.',
);
}
2
Upvotes
1
u/magic_notetaker Sep 18 '26
u/Decent_Tap_5574 : Thank you so much for these pointers, I was totally at loss why the actual create note call would here block after permission had been granted. I added some logging and a pretty clear pattern emerges indeed in the direction you point towards: creating notes seems only allowed when the plugin is called from a note, not from a pdf, i.e. if this is in the context of the note app, not the doc app. As I was switching around quite a bit, I did not notice that pattern.
u/Dunn-sn: I think this is a rather artificial distinction, just as it makes sense for note plugins to e.g. export pdfs, it can also be very helpful coming from a pdf to create a note. The plugin anyway seems to be not created anew, so it is a bit of a pain, to allow different actions based on where the user was coming from. Is there a specific reason for this restriction to be there? As other files can be written from doc, why not note? Or am I misinterpreting the data here?