vtt-compendium-folders icon indicating copy to clipboard operation
vtt-compendium-folders copied to clipboard

V11 migration - ensure macro never called twice quickly

Open farling42 opened this issue 1 year ago • 2 comments

Thanks for all the hard work you've done in the past for CF.

For the migration, is it possible to provide a lock so that the migration function can't be called again before a previous call has finished?

Since CF has always cached the currently open folder, this can cause problems if trying to migrate two compendiums at the same time (since the most recently started compendium will be in the cache, and cause the other compendium to be wrongly set up).

farling42 avatar May 29 '23 22:05 farling42

Hi, sure I can add a flag that is set when the module runs a migration. I initially intended for you to only be able to run one migration at a time, but i can see how running multiple migrations would break things

earlSt1 avatar May 30 '23 08:05 earlSt1

I have a lot of compendiums in shared modules, so I'm using the following script, but others might not be so careful:

for (const pack of game.packs.values()) {
     const packid = pack.metadata.id
     const locked = pack.locked;
     console.log(`Migrating ${packid}`)
     if (locked) pack.configure({locked:false});
     await game.CF.FICFolderAPI.migrateCompendium(packid);
     if (locked) pack.configure({locked:true});
     console.log(`Finished ${packid}`);
}
console.log('** FINISHED CF MIGRATION **')

My first attempt at a script was using forEach, but that didn't seem to serialize the calls to migrateCompendium properly.

farling42 avatar May 30 '23 09:05 farling42