Skip to main content
Topic: Conversion failed: File is already in use (Read 779 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Conversion failed: File is already in use

Quote
1 out of 1 tracks converted with major problems.

Source: "E:\Music\~Anisong\201807\[180808] TVアニメ「銀魂 銀ノ魂篇」ED2テーマ「ヒカリ証明論」/CHiCO with HoneyWorks\01. ヒカリ証明論.flac"
  An error occurred while finalizing the encoding process (File is already in use) : "E:\Music\~Anisong\201807\[180808] TVアニメ「銀魂 銀ノ魂篇」ED2テーマ「ヒカリ証明論」/CHiCO with HoneyWorks\01. ヒカリ証明論.opus"
  Conversion failed: File is already in use

I think the reason is Google's Backup and Sync tool, my convert destination folder is watched by Backup and Sync tool.


Re: Conversion failed: File is already in use

Reply #1
Tried more encoders, like Nero AAC 1.5.4, LAME 3.99, QAAC, OGG aoTuV 20110424 and opus 1.2,
I found only Nero AAC and QAAC can successfully complete the encoding in the folder watched by Backup and Sync tool.

I guess the reason is ID3 tags? AAC format does not use ID3 tag so the encode is successful?

Another problem is Google Backup and Sync can only add exceptions by file extensions so the temp files just like "temp-hash.opus" generated by foobar2000 are all synced, that's really annoying. I suggest to change the temp file name to "hash-opus.temp" so I can add "*.temp" to the exception list of Backup and Sync tool.

Re: Conversion failed: File is already in use

Reply #2
The converter stops writing to the file and closes it when it's done. Then your sync tool opens it to sync it. Only foobar2000 immediately attempts to copy the tags over to the file, which opens it again.

Re: Conversion failed: File is already in use

Reply #3
So how to solve it?
My suggestion is:
1. Change the temp file name format from "temp-hashvalue.ext" to "ext-hashvalue.temp". So I can add "*.temp" to sync tool exceptions.
2. Rename temp file to the rename pattern format after writing tags to temp file.

Re: Conversion failed: File is already in use

Reply #4
I also got another problem about "file in use" in foobar2000 with Google Backup and Sync. When a file is syncing in Backup and Sync tool, I can edit it with WinRAR (if it's a .rar package) or rename it (in Explorer or use Foobar2000's rename util), but if I edit the tags of it or attach images in Foobar2000, the "file in use" warning comes.

Re: Conversion failed: File is already in use

Reply #5
Converter may get an update to better handle use cases like this. In the mean time you could manually convert to a temporary directory and move finished files to the target.

As for your latest post, foobar2000 requires exclusive access to files while changing them. You probably wouldn't want a file to be corrupted during upload.

Re: Conversion failed: File is already in use

Reply #6
But the file is still locked even the upload is complete. And if I can rename it in explorer, edit it in other software, why I cannot edit tags of it in Foobar2000?

Re: Conversion failed: File is already in use

Reply #7
So the backup utility is bugged? You can rename a locked file but you can't for example delete it or copy a replacement file over.

Re: Conversion failed: File is already in use

Reply #8
I think it's not bugged, and the files are not even locked since I can rename, edit and delete them when syncing and after syncing complete. They're treated as "locked" only in Foobar2000.
Update: Also found this, once a file is treated as locked in Foobar2000, it will alway be treated as locked unless Foobar2000 is restarted.

Re: Conversion failed: File is already in use

Reply #9
It appears your backup utility keeps the files open with read/write sharing permitted, but foobar2000 needs exclusive access to the file to write to it.

Re: Conversion failed: File is already in use

Reply #10
So will there be a fix for this? Does foobar2000 really need exclusive access to audio files?

Re: Conversion failed: File is already in use

Reply #11
It always has wanted exclusive access for writing (nothing should need to read the files while they're being written to.), and read-only sharing when reading the files. (nothing should be writing to the files while they're being read.)

Re: Conversion failed: File is already in use

Reply #12
But as mentioned before, I've tried .docx files with Microsoft Word, .rar files with WinRAR, .jpg images with XnView, .txt files with Emeditor and rename with Explorer, they can all edit when syncing. And on Foobar2000 side, not only when syncing files, but also after the syncing is complete the edit is not allowed (the file operation menu of Foobar2000 is only the exception).

Re: Conversion failed: File is already in use

Reply #13

Look at this, Google Backup and Sync tool can even upload a file which is already downloading.

Re: Conversion failed: File is already in use

Reply #14
And as I said, foobar2000 wants exclusive access. Those other programs probably allow the default read sharing when writing files.

Re: Conversion failed: File is already in use

Reply #15
And the exclusive access for writing to audio files of Foobar2000 is a "must have" permission? I know some programs are not allowed to reading files when they are on edit, but can't understand why Foobar2000 cannot write to audio files when other programs are reading them.

Re: Conversion failed: File is already in use

Reply #16
To not cause inconsistent behavior in those programs?

Re: Conversion failed: File is already in use

Reply #17
This is a very ugly problem for multiple reasons.

I'm surprised Google does not start syncing the files a few seconds after the last write to the file occurred, that would generally cause less headache for everyone as far as I can see. I do exactly this in every single app dealing with monitoring folders and yet to hear a single complaint about it.

A foobar2000 Converter task is not a monolithic operation that could possibly write audio and tags without unlocking the file - foobar2000 invokes an encoder program, hands it the data, waits for it to finish its job, then continues working with its output - writing tags and so on.

Writing of the tags may rewrite the whole file in some of the cases, which requires exclusive access (write new content to a temp file alongside the original media file, replace old file with new).

The use of .tmp extension is a good idea and I am giving it a serious consideration. However it is not without side effects. I am very sure someone runs a Converter config that will break from this, due to external encoder program relying on the extension to know what format to write - for an example, FFmpeg without a -f parameter.

Edit: I'm working on an option to encode to a temporary folder and move files to the intended folder once tagged, I hope that will address this issue.

Re: Conversion failed: File is already in use

Reply #18
And also this file lock problem?

Re: Conversion failed: File is already in use

Reply #19
Fine - from version 1.4.1 I'm making tag update operations open files with FILE_SHARE_READ, so someone else can be reading the file as long as they opened it with FILE_SHARE_WRITE permitting us to open for writing. Hopefully this won't have any strange side effects.

 
SimplePortal 1.0.0 RC1 © 2008-2018