1
Wrong document displayed in Document Viewer
Problem reported by Jo Joseph - 3/6/2024 at 10:47 PM
Resolved
Hi,
I recently updated my DocumentUltimate version from 4.0 to 6.6. Since then I have noticed multiple cases of wrong document being displayed in the viewer.
We have noticed that the files that are being incorrectly shown has the same modified date as the actual file. But the filename and file size are different. This issue could be fixed by disabling the cache but we would prefer to have the cache enable to have better performance. This is the code used - 
documentViewer.Document = new MemoryFileProvider(string.Join("", Id.ToString(), Filename), memoryStream, result.Data.Modified); 
Here the Id and Filename are different for both documents.They also have different file size.But the extension and modified date are the same. Could you advise if there is any fix for this issue without disabling the cache. Is this issue fixed in any of the future versions?

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Resolution
From the docs:

For generating the cache key, to uniquely identify a document file, we use a string combination of file extension, file size and file date, this way cache collisions do not occur and we can reuse the cached file even if the file name before extension is changed (file1.docx and file2.docx have same cache key because it's still the same document according to file extension, file size and file date).

File providers like FileSystemFileProvider (a file on disk, on Amazon S3, on Azure) can provide file size and file date automatically however some file providers will not have this knowledge, e.g.StreamFileProvider, MemoryFileProvider (how could they know date modified of your data in a byte array or a stream?).

So for this purpose, these kind of providers have an additional property or constructor argument named DateModified and/or Size. You need to specify these to ensure you uniquely identify a document.


For MemoryFileProvider, the size is already known as it's in memory. If the size is really different than the cache key should also be different. Extension part of the file name is important, not the whole file name. Also latest version is 6.9.6 why do you stay at 6.6?


Reply to Thread