There are two ways to list the files in a storage, which could return different values. Loop over the index file entries, and the data entries.

The right way

Looping over the items in the Index file is the right way; if a file is added to the file storage, first an index is created and second the binary data of the file itself is appended at the end of the data file. When a file is deleted from the file storage, the data in the data file remains (its not purged). The only thing that happens when you delete a file, is that the offset pointer in the index file is removed. When you update the contents of a file (so; you override a file with another one, using the same file identifier), the index itself will remain in the index file, the old data in the data file remains, and the new data is appended. The offset in the index file is ofcourse updated to the newly added data in the data file.

If you want to loop over the guids in the index file in your own code, use the "public static List<Guid> GetAllFileIdentifiersBasedUponFileStorageIndexFile(string containerName)" method of the FileStorageFacade class. You can experiment yourself with this by using the command line tool; below you can see that the file storage '26-2' has 9889 files according to the index file.

H:\Proj\\NFileStorages\IncrementalData\26_2_done>FileStorageCmd.exe count 26-2
. 9889 (2472 files/sec, 00:00:04 mins) Count........................................................
9889 files found
This operation took 4138 msecs

The other way

The other way to loop over the files in the file storage, is to loop over the items in the data file. Deleted, or overriden files will also be part of the enumeration. To loop over the items according to the data file, use the "public static IEnumerable GetAllFileIdentifierEnumerableBasedUponFileStorageDataFile(string containerName)" function of the Facade. You might wonder why there's even functionaltiy to loop over items if they are deprecated (either deleted, overriden). One benefit is ofcourse it could allow us to undo a deletion of a file, if it was deleted by accident. Another benefit is that it can allow us to revert to previous version of a specific file. The primary reason why the looping over the data file exists, is because it allows us to re-generate the index file from a data file, see recreate the index file from the data file. You cannot use the command tool to access this function as it wouldn't make sense.

Last edited Mar 13, 2009 at 9:29 PM by barkgj, version 4


No comments yet.