Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / FileAttributesStore_Mixed.cs
blob663f9154a83d4a1d549c0961f6fcff0d2699a85a
1 //
2 // FileAttributesStore_Mixed.cs
3 //
4 // Copyright (C) 2004 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
27 using System;
29 namespace Beagle.Daemon {
31 public class FileAttributesStore_Mixed : IFileAttributesStore {
33 FileAttributesStore_ExtendedAttribute store_ea;
34 FileAttributesStore_Sqlite store_sqlite;
36 public FileAttributesStore_Mixed (string directory, string index_fingerprint)
38 store_ea = new FileAttributesStore_ExtendedAttribute (index_fingerprint);
39 store_sqlite = new FileAttributesStore_Sqlite (directory, index_fingerprint);
42 // We always have to query the Sqlite store first, because of our
43 // EA nightmare scenario: a file whose permissions or ownership get
44 // changed after the EAs have been attached. Thus attributes in
45 // the database always trump those found in EAs.
47 // FIXME: If we have write access to the path but it has attributes
48 // stored in the sqlite file attributes db, we should attach them
49 // to the file with EAs and delete the record from the db.
51 public FileAttributes Read (string path)
53 FileAttributes attr;
54 attr = store_sqlite.Read (path);
55 if (attr == null)
56 attr = store_ea.Read (path);
57 return attr;
60 public bool Write (FileAttributes attr)
62 return store_ea.Write (attr) || store_sqlite.Write (attr);
65 public void Drop (string path)
67 store_ea.Drop (path);
68 store_sqlite.Drop (path);
71 // Transactions do nothing for the EA store, so there is no
72 // point in calling it BeginTransaction or CommitTransaction
73 // on store_ea.
75 public void BeginTransaction ()
77 store_sqlite.BeginTransaction ();
80 public void CommitTransaction ()
82 store_sqlite.CommitTransaction ();