F-Spot smbfs problems

I have started using F-Spot for managing my photos a year ago. Since I wanted to keep my photos on my photos on my file server I have accessed them using Samba File System (smbfs). At first everything worked OK, but a few months ago problems appeared. When importing images I got file system error regarding access permissions.

Today I have decided to stop piling new photos in a temporary directory and get to the core of the problem. So I downloaded F-Spot source code and started exploring. I have located the problem to the FileImportBackend.cs file where a new directory is created using System.IO.Directory.CreateDirectory. This method can also handle recursive creation of directories which was exactly what happened in my case. To investigate further I have written my own method to do the recursive step and did a few more tests.

Surprisingly the problem turned out to be timing: when using a normal file system the changes like directory creation are instantaneous from the perspective of the applications. Samba, however, is a network file system ... and apparently this is not the case here. Because of this the CreateDirectory method created the parent directory and proceeded to create the child directory before the parent was actually created ... and that resulted in access permission exception.

Testing this theory was easy: I inserted a one second sleep at the end of recursion step and viola! Everything worked just fine. I am posting a diff patch here, and I am still considering if I should submit it to the F-Spot project ... after all it is an ugly hack. But it works.

Written on Feb. 7, 2009 at 11:26 p.m.

Attachments

f-spot.smbfs__1.patch
blog comments powered by Disqus