# Cache Issues with Duplicate Event Detection After Copy/Paste

**URL:** <https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653>\
**Category:** FMOD Studio\
**Tags:** studio-scripting-api\
**Created:** [March 3, 2025, 4:49pm UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653 "2025-03-03T16:49:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucafusi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/lucafusi/32/681_2.png) [@lucafusi](https://qa.fmod.com/u/lucafusi)\
**Post date:** [March 3, 2025, 4:49pm UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/1 "2025-03-03T16:49:40Z")

</div>

We validate event names to check for dupe paths before path-stripping our events and creating a header file for our game to use. The script correctly identifies actual duplicates, but sometimes in a session after event copy/paste operations, it can report “ghost” duplicates that don’t actually exist anymore.

Closing and reopening FMOD and rebuilding the header file correctly builds it without reporting issues, despite no events having been changed in between.

I’m guessing it’s some kind of caching issue, but even deleting the .cache and .unsaved folders while the program’s still open won’t unblock the script. FMOD must be relaunched.

The issue appears when using the FMOD Studio scripting API, specifically:

- `studio.project.model.Event.findInstances()`
- Accessing `event.name` and `event.getPath()`
- After performing copy/paste operations on events

Can you think of any workaround for this, or would you be willing to take a look at the script itself?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [March 4, 2025, 2:37am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/2 "2025-03-04T02:37:34Z")

</div>

> [@lucafusi](#):
>
> Can you think of any workaround for this, or would you be willing to take a look at the script itself?

Posting the script, as well as a short series of steps that reproduce the issue, would be great. Also, what version of FMOD Studio are you using?

---

<div class="post-metadata">

**Author:** ![lucafusi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/lucafusi/32/681_2.png) [@lucafusi](https://qa.fmod.com/u/lucafusi)\
**Post date:** [March 4, 2025, 4:29pm UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/3 "2025-03-04T16:29:28Z")

</div>

Hey Leah,

This is the script we’re working with, and we’re still on 2.02.20 as a core. I’ve been on some variant of 2.02.20 to 2.02.27 all throughout dev, and this behavior’s persisted.

A common repro would be to create a bunch of events and ensure the script runs properly with no errors. You shouldn’t see a dialog or anything if this went well.

Then, copy/paste an event a bunch of times (as if you were planning to rename the pasted events, using the original event as sort of a template for your new events – super common for us), rename all your pasted events to unique names, and try again. You should run into the issue of it thinking that events have duplicate names even though you can see they’re all unique. That’s where I feel like some kind of caching is interfering.

Hopefully you have some insights on this! The seconds and minutes of relaunching the program with our project just to build after implementing a bunch of new events really do add up and I’d love to fix it for good.

Thanks,  
Luca

P.S. The file’s been uploaded as .txt to get around upload type restrictions, but it’s obviously supposed to be a .js file.  
[exportFMODTable.txt](https://qa.fmod.com/uploads/short-url/2GjhV6xtgWeQ7NuLnnUZIvTGYR4.txt) (12.9 KB)

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [March 6, 2025, 6:44am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/4 "2025-03-06T06:44:24Z")

</div>

Thanks for the script and repro Luca, I’ll take a look and get back to you soon.

---

<div class="post-metadata">

**Author:** ![lucafusi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/lucafusi/32/681_2.png) [@lucafusi](https://qa.fmod.com/u/lucafusi)\
**Post date:** [March 7, 2025, 1:18am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/5 "2025-03-07T01:18:17Z")

</div>

Cheers, thanks Leah!

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [March 12, 2025, 5:57am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/6 "2025-03-12T05:57:17Z")

</div>

After some testing, this does appear to be an issue with how Studio handles finding entities that are unsaved, as they can be still fetched using `studio.project.model.Event.findInstances()` when they probably shouldn’t be. I’ve added it to our bug tracker, but in the meantime, I’d recommend iterating over events from `studio.project.workspace.masterEventFolder.items` instead, which should only contain events present in the event editor’s hierarchy.

Here a snippet demonstrating how you might handle this:

```js
var allEvents = [];

function getAllEvents(item) {
    if (item.isOfType("EventFolder")) {
        // item is an event folder, recurse on folder's items
        item.items.forEach(getAllEvents);
    } else if (item.isOfType("Event")) {
        // item is an event, add it to the array of all events
        allEvents.push(item);
    }
}

studio.project.workspace.masterEventFolder.items.forEach(getAllEvents);
console.log(allEvents);

```

Give that a shot and let me know how it goes.

---

<div class="post-metadata">

**Author:** ![lucafusi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/lucafusi/32/681_2.png) [@lucafusi](https://qa.fmod.com/u/lucafusi)\
**Post date:** [March 15, 2025, 2:22am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/7 "2025-03-15T02:22:07Z")

</div>

Looks like we’re cooking, Leah. Thank you so much for the help! So many relaunches saved!

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [March 17, 2025, 2:38am UTC](https://qa.fmod.com/t/cache-issues-with-duplicate-event-detection-after-copy-paste/22653/8 "2025-03-17T02:38:49Z")

</div>

No problem! Feel free to get in touch again if you run into any other issues.
