I'm in the process of making my app compatible with Tauri 2.0 after upgrading to it recently. I'm trying to access files in the resource folder by fist calling path.exists like this:
let filePath = await path.join(await path.resourceDir(), "some_folder", "file.xlsx");
let fileExists = await exists(filePath);
This looked pretty much the same on Tauri 1.x and worked, but now on Tauri 2.0 I'm getting an exception:
forbidden path: D:\path_to_repo\src-tauri\target\debug\some_folder\file.xlsx
Two weird things about all this:
This exception only happens if the file does not exist. If it exists, then the code above simply returns true as you would expect.
If I'm calling it with baseDir specified (await exists(filePath, {baseDir: BaseDirectory.Resource})), it doesn't result in an exception, but instead exists always returns false (I guess that makes sense now that I think about it).
Although I'm not 100% sure how the new permission system works yet, I think my app should have the correct permissions to interact with the file:
In the end, using a base directory, this code worked:
let filePath = await path.join("some_folder", "file.xlsx");
let fileExists = await exists(filePath, {baseDir: BaseDirectory.Resource});
In order to check whether it is a permission issue or not, I ran the same code for desktop files and experienced no issues doing that. All the results were correct and no exception happened.
Reproduction
Here are the various tests I did, always for both an existing and a non-existing file. First are the resource accesses with the mentioned exception and the wrong results, followed by the desktop accesses with all correct results.
let filePath = await path.join(await path.resourceDir(), "some_folder", "non_existing_file.xlsx"); // non-existing file
let fileExists = await exists(filePath);
Correct results for this one. Not that important, since the access technically shouldn't give correct results (you're appending the whole path to the base path), but it did work for the desktop directory, so...
let filePath = await path.join(await path.resourceDir(), "some_folder", "file.xlsx"); // either existing or non-existing file
let fileExists = await exists(filePath, {baseDir: BaseDirectory.Resource});
Describe the bug
I'm in the process of making my app compatible with Tauri 2.0 after upgrading to it recently. I'm trying to access files in the resource folder by fist calling
path.exists
like this:This looked pretty much the same on Tauri 1.x and worked, but now on Tauri 2.0 I'm getting an exception:
forbidden path: D:\path_to_repo\src-tauri\target\debug\some_folder\file.xlsx
Two weird things about all this:
true
as you would expect.baseDir
specified (await exists(filePath, {baseDir: BaseDirectory.Resource})
), it doesn't result in an exception, but insteadexists
always returnsfalse
(I guess that makes sense now that I think about it).Although I'm not 100% sure how the new permission system works yet, I think my app should have the correct permissions to interact with the file:
In the end, using a base directory, this code worked:
In order to check whether it is a permission issue or not, I ran the same code for desktop files and experienced no issues doing that. All the results were correct and no exception happened.
Reproduction
Here are the various tests I did, always for both an existing and a non-existing file. First are the resource accesses with the mentioned exception and the wrong results, followed by the desktop accesses with all correct results.
Expected behavior
No exception for this one:
Correct results for this one. Not that important, since the access technically shouldn't give correct results (you're appending the whole path to the base path), but it did work for the desktop directory, so...
Full
tauri info
outputStack trace
No response
Additional context
No response