Files being intermittently erased from plugin data folder

This has been going on for a long time. Photoshop will intermittently erase files form the plugin data folder. This may only happen to a small percentage of users… but I have a lot of plugin users so I have to do tech support for this a lot and I don’t have any good answers to give to the users.

My plugins store the user’s plugin activation in a txt file inside of the plugin data folder. That is the only folder the plugin is allowed to save to without have to go through the folder picker dialog, or at least that was the case when I first created the plugin activation system a few years ago.

For extendscript years ago, on Windows I would store the plugin activations under the C:\ProgramData folder and for Mac I would store the plugin activations the Users/Shared folder. I never had issue with using these folders and would prefer to use those with UXP too. The plugin activations file always stayed is these folders, even in the case where Photoshop was uninstalled and reinstalled, updated, or whatever.

Is there a way for UXP to save to the windows ProgramData folder or the Mac Users/Shared folder without requiring any special permissions to be set up and without prompting the folder selection dialog? Anything that requires user intervention will just confuse people and cause tech support so I don’t want anything that requires users to need to steer the wheel when activating the plugins.

1 Like

Thanks for this alert @ddbell. I’ve had no reports of this . . . yet. But I will be watching for it now. My plugins make extensive use of the “PluginData” folder for storing plugin data. I had this problem with CEP plugins, but so far no reports with UXP plugins. I have created manual backup and restore functionality for users for “PluginData” files, but that definitely requires user implementation for it to be an effective solution for lost files.

Do you know specifically if all the plugin data is being lost, or just certain files? I’ve found that things like file and folder tokens look like they are “lost” sometimes when the user changes something on their computer, but it’s a change in their file structure that is the issue.

How do users know the data has been lost? Do they receive an error message? Have you had them look in the “PluginData” folder to verify that the .txt file is missing?

I store software activations in a txt file and user presets in a csv file. Some users reports the plugins deactivating and needing to enter the key again. Some users have also reported there presets being lost. However, most users don’t save presets so losing the activation txt file is far more commonly reported.

I have seen this randomly on my test machines when updating Photoshop, but that is the only time I’ve seen it myself. Some users have reported it happening without updating Photoshop too. A few users have this happen very frequently but most cases are seldom for users.

I need to revisit storing data in the C:\ProgramData folder on Windows and the Users/shared folder on Mac. With CEP and extendscript that is what I used and never had any issues because that was outside of the Photoshop folder structure. Users could reinstall Photoshop and their files would still be there. When UXP was first released, this wasn’t possible. It may be now with persistent tokens. However, I was wanting a system without the users needing to do any special opt-ins because anything that involves user input creates more tech support from confused users. I just want them to enter a key and click activate without having to do anything else.

In one of my plugin I’m storing data in
Mac: /Users/<username>/Library/Application Support/
Windows: C:\Users\<username>\AppData\Roaming\

This is how I get the entry without a folder dialog but you need to set this permission in the manifest:

"requiredPermissions": {
     "localFileSystem": "fullAccess"
 }

This permission does not require any user intervention while using the plugin.

const fs = require("uxp").storage.localFileSystem;
const os = require("os");

const getPathEntry = async () => {
        let p;
        const homedir = os.homedir();
        const platform = os.platform();
        if (platform === "darwin") {
            // Mac
            p = path.join(homedir, "Library", "Application Support");
        } else {
            // Windows
            p = path.join(homedir, "AppData", "Roaming");
        }
        const pathEntry = await fs.getEntryWithUrl(p);
        return pathEntry;
};

getEntryWithUrl was implemented with UXP 6.5 (Photoshop 24.2).

1 Like

Awesome, thanks! This looks promising. I wasn’t aware of the localFileSystem fullAccess. I’m assuming that is a manifest 5 addition.

Yes, permissions are part of manifest v5.

Should your plugin clean its own data when uninstalled?

Not really sure how that would be possible with UXP if using any location other than the plugin data folder. That is one reason that I wanted to keep using the plugin data folder. However, if it continues to have intermittent issues with losing data then it kind of forces looking for an alternative.

In any case, for me it’s just a tiny txt file containing the users activation. It’s probably not a huge deal if the file stayed, but not ideal I guess.

What about non-english operating systems? Does path.join automatically adjust the path text based on OS language?

It’s independent of the OS localization. These values work for all.

1 Like