# All .bytes files being deleted and banks being copied repeatedly when Import Type is set to AssetBundles

**URL:** https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943
**Category:** Unity
**Created:** [August 14, 2019, 4:29pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943 "2019-08-14T16:29:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![edwinlyons](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@edwinlyons](https://qa.fmod.com/u/edwinlyons)
#### Post date: [August 14, 2019, 4:29pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/1 "2019-08-14T16:29:44Z")

</div>

I’ve just updated from FMOD 1.x to 2.00.03 and I’m seeing some fairly serious issues when the import mode is set to Asset Bundles.

- The FMOD banks are being deleted then copied into the Assets folder repeatedly every few seconds.
- All files that end in .bytes in the project are being deleted

This is due to faulty logic in EventManager.CopyToStreamingAssets.

This line is incorrect as it assumes that the files will be in streaming assets.  
`var targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName).Replace(RuntimeUtils.GetCommonPlatformPath(Application.streamingAssetsPath + '/'), "");`

Instead something like this might be better:  
`var targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName).Replace(RuntimeUtils.GetCommonPlatformPath(bankTargetFolder), "");`

But more fundamentally, the principle of searching for any .bytes files and deleting them if they don’t match the name of a bank seems entirely flawed. I get why that might make sense for a .banks file but it certainly doesn’t for a .bytes file that may contain any binary data used in the project.

This issue was exacerbated in this release by the addition of SearchOption.AllDirectories to this line:

`string[] currentBankFiles = Directory.GetFiles(bankTargetFolder, "*." + bankTargetExension, SearchOption.AllDirectories);`

This wasn’t there in 1.x which meant that at worst it would delete .bytes files in the Assets folder but not in any child directories.

All in all this approach seems dangerous and a bit lazy!

---

<div class="post-metadata">

### Author: ![edwinlyons](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@edwinlyons](https://qa.fmod.com/u/edwinlyons)
#### Post date: [August 19, 2019, 4:22pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/2 "2019-08-19T16:22:10Z")

</div>

I’d be great to have a response to this!

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [August 21, 2019, 12:58am UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/3 "2019-08-21T00:58:32Z")

</div>

Thanks for the feedback, we will look into this for the upcoming release.

---

<div class="post-metadata">

### Author: ![abertrand](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abertrand](https://qa.fmod.com/u/abertrand)
#### Post date: [September 25, 2019, 2:24pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/4 "2019-09-25T14:24:45Z")

</div>

Hi there, I’m having the same issue with FMOD 2.00.03. The big issue with that is that I cannot use the AssetBundle mode at all.

I would like to add that in this method, the line :

if (!eventCache.EditorBanks.Exists((x) =\> targetShortName == x.Name + “.” + BankExtension))

isn’t correct as **BankExtension** is a static string equal to “bank”. Instead it should use the **bankTargetExension** string generated just a few lines above that will hold either “bytes” or “bank” depending on the context.

In the end, I successfully fixed the issue by using this piece of code :

//Code …

string targetShortName = RuntimeUtils.GetCommonPlatformPath(bankFileName);  
targetShortName = Path.GetFileName(targetShortName);  
if (!eventCache.EditorBanks.Exists((x) =\> targetShortName == x.Name + “.” + bankTargetExension))  
{  
//Code…  
}  
…

Hope it helps and hopefully we’ll get a fix soon.

---

<div class="post-metadata">

### Author: ![abertrand](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abertrand](https://qa.fmod.com/u/abertrand)
#### Post date: [September 26, 2019, 7:37am UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/5 "2019-09-26T07:37:46Z")

</div>

Actually it seems it has been fixed in 2.00.04. It’s working alright now.

---

<div class="post-metadata">

### Author: ![edwinlyons](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@edwinlyons](https://qa.fmod.com/u/edwinlyons)
#### Post date: [October 4, 2019, 2:27pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/6 "2019-10-04T14:27:34Z")

</div>

@cameron-fmod I’m still having this issue with fmod 2.00.04. All the .bytes files in the project are being deleted continuously.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [October 7, 2019, 4:05am UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/7 "2019-10-07T04:05:24Z")

</div>

Are you able to share the log from Unity?

---

<div class="post-metadata">

### Author: ![edwinlyons](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@edwinlyons](https://qa.fmod.com/u/edwinlyons)
#### Post date: [October 7, 2019, 10:05am UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/8 "2019-10-07T10:05:25Z")

</div>

Hi @cameron-fmod

I’m afraid I can’t right now as I’ve worked around it by setting a TargetAssetPath folder for the FMOD files. The issue only occurs if the TargetAssetPath is empty (the default) or if it’s set to a folder with other .bytes files in it.

The code that does this is in EventManager.CopyToStreamingAssets. I’ve commented out the “Clean out any stale .bank files” block as well, to be safe.

The crux of the issue is that the “Clean out any stale .bank files” doesn’t do what it says it does. If the project is using asset bundles, it goes and deletes any “.bytes” files that are in the TargetAssetFolder. If that TargetAssetFolder is not set, then that deletes any .bytes files in the project. .bytes files are a standard Unity file extension for binary data, so this doesn’t feel like it’s ever a safe thing to do - especially if the TargetAssetFolder isn’t set. You should have a better way to identify assets that belong to FMOD in this situation - either special filenames or perhaps Unity asset tags.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [October 13, 2019, 10:25pm UTC](https://qa.fmod.com/t/all-bytes-files-being-deleted-and-banks-being-copied-repeatedly-when-import-type-is-set-to-assetbundles/14943/9 "2019-10-13T22:25:17Z")

</div>

That is a valid point, I have raised this a task to investigate further.
