Page MenuHome

Fix T87621: Win32 Do Not Create Preview Thumbnails for Offline Files
ClosedPublic

Authored by Harley Acheson (harley) on Apr 27 2021, 9:59 PM.

Details

Summary

There are some situations where a file might be visible when listed, but aren't actually fully-present on the file system. The most notable is when files are in OneDrive and are currently offline.

The problem with this is that if you browse to a folder containing offline files while in thumbnail view, the process of creating thumbnails will necessarily require the downloading of all files in that folder. This can take a very long time, and be quite confusing, if a large number of files and/or if your internet connection is slow.

This patch checks for this status when getting file attributes. Some offline systems use FILE_ATTRIBUTE_OFFLINE to indicate this. OneDrive also used this attribute until 2019 and then starting using FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS. This patch treats them both as the same as our internal FILE_ATTR_OFFLINE.

With that attribute set this patch just makes such files not available for thumbnails.

For example, I have two images in my OneDrive folder. One shows a green checkmark because it is online and available. The other shows a cloud because it is not.

Viewing in the Blender File Browser they will look like this, with the offline one getting a generic image icon. However a small icon is added to indicate that it is an offline file.

But after viewing, the offline file is still offline.

@Ray Molenkamp (LazyDodo) - Not sure how to tell how old this FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS define is and in our current minimum Windows API version.

Diff Detail

Repository
rB Blender

Event Timeline

Note that the subject mentions "Win32" only because this only fixes this issue on Windows, but the fix itself is generic. If there is a way to detect this state on Mac, for instance, they should also set entry.attributes FILE_ATTR_OFFLINE and then it will work the same on that platform.

Not sure how to tell how old this FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS define is and in our current minimum Windows API version.

while i can't seem to find a definitive statement on when this got added, given it's not doing any imports, I'm not expecting compat issues, worst can happen is that win 8.1 doesn't set the flag which isn't any worse than not checking for it which is the current situation

Since Windows can still see these thumbnails, this solution appears to be a shortcut.
But I think it's fine for now. (Better than downloading the files).

This revision is now accepted and ready to land.Apr 28 2021, 9:20 PM
Harley Acheson (harley) edited the summary of this revision. (Show Details)

Now including an icon on the offline thumbnail to indicate that it is offline. Updating the captures in main description.

Julian Eisel (Severin) accepted this revision.EditedMay 19 2021, 2:58 PM

Not sure how exactly we use FILE_ATTR_OFFLINE and what side effects it could have to add more checks for it, but I'm not too worried since this is all runtime data. So accepting this as: "Yeah I didn't check details, but I'm not too worried and I know Harley won't just disappear after committing".

@Julian Eisel (Severin) - Not sure how exactly we use FILE_ATTR_OFFLINE and what side effects it could have...

We haven't used that at all yet. It was part of a number of flags I added that could be used to store OS file information. This one though needs its comment updated and so will do so.

...but I'm not too worried....Harley won't just disappear after committing".

Yes, no worries. I plan to be around for at least another year or two, probably much more.

Updating to current state of master, and also to improve comment for FILE_ATTR_OFFLINE usage