Rescan Folder

Started by ben, July 26, 2017, 08:23:05 PM

Previous topic - Next topic

ben

Hello,

i need to "rescan an iMatch folder" by script and cannot find the right function.

In VB i used the following:
Database.AddFolder(myFolder, True)

I know that iMatch automatically rescans folders in most cases, but unfortunately not in this case.
  - Automatic Rescan is enabled
  - The folder mirrors a cloud folder (OneDrive) and thus gets updated outside of iMatch. Even when iMatch is not even running.

I found a similar thread, where Mario says that there is no such endpoint. Still true?
Is there some kind of workaround?

https://www.photools.com/community/index.php?topic=6736.msg46650#msg46650


Thanks,

Ben


Mario

IMatch automatically rescans folders when it detects a change in the last modified timestamp of the folder or when Windows sends certain file systems notifications.
Why do you need to trigger a rescan from a script?

Note: Triggering a rescan from a script could even cause problems! When IMatch receives "folder modified" or "file modified" messages from Windows it starts a watch. When it has not received additional messages for some time (10 seconds or so) it rescans the folder.

This is important because many popular apps work with temporary files, e.g. when saving an image. They don't overwrite the original file, but save a 'new' copy to a temporary file and if this works, they delete the original file and rename the temporary file.

If a script would jump in and run a hard rescan in-between, IMatch may have to deal with issues such as locked files, temporary files which suddenly vanish. original files which are deleted (and thus are removed from the database) but actually are "there" again a few seconds later etc.

I doubt that script authors would consider all that...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

QuoteWhy do you need to trigger a rescan from a script?

I use a folder, that is synchronized to the cloud (OneDrive).
Most of the time, files are downloaded from the cloud to this folder (not uploaded).
The most common changes to this folder are: new files added from the cloud, files removed

This folder gets updated outside of iMatch and often when iMatch is not running.
In most cases, these changes are not recognized by iMatch.

In iMatch5 i had a small script that rescans this folder and refreshes some data-driven categories which depend on images in this folder.



ubacher

QuoteI doubt that script authors would consider all that...

What about user initiated rescans (by hand)? Would they not have to consider the same?
And a script which only initiates a rescan is no different from doing it by hand - just more convenient.

(I can see the need to be careful when a script manipulated files and then immediately does a rescan. )

ben

Hey Mario,

do you have another suggestion or workaround?
I don't need the scripting endpoint, though currently the specific folder gets not updated in iMatch if files are changed in OneDrive (see my description above).

Ben

Mario

Does the 'last modified'' timestamp of the folder change when OneDrive synchronizes it with the cloud?
IMatch detects changed folders by comparing this timestamp with the timestamp recorded in the database. Or when it receives "folder modified" messages from Windows while it is running.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Yes. The last modified timestamp of the One drive folder changes correctly when I add files.

If I then open up IMatch the folder icon of the One drive folder has those two blue round arrows.
The last files are missing.

If I select rescan,the new files show up and the blue arrows vanish.

Mario

Keep an eye on the log file. IMatch reports updated folders there, and also when it receives messages from Windows.
AddOrUpdate folder is logged, and then whether or not the folder was found outdated
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

I checked the logfile several times, but couldn't find the problem's reason.


I did the following steps to produce the log file which is attached:

1) "Rescan" local OneDrive folder in iMatch to make sure it's up to date
2) Set Debug-Log-Mode
3) Closed IM
4) Let OneDrive download a file from the cloud to the local OneDrive folder
5) Opened IM and let it run for 10 Min in Debug-Log-Mode, without working with IM
  - The OneDrive folder in the media&Folders Views shows the blue arrows (see attachment)
  - The new file is not shown in IM
  - I waited for 2 hours, in case IM works in the background
    -> no changes
6) Rescan OneDrive folder (right-click -> "rescan now") in IM
  - The new file appears in IM (20170806_132002.jpg)
7) Switch to Normal-Log-Mode


Does this help?

Ben

Mario

Works here. I've added one folder from OD to an IMatch database.

1. Create a new file in the folder.
IMatch marks the folder and rescans it 10 seconds later, bringing the new file into the database.

2. Upload a file to this folder on OD from my smart phone.
OD syncs the file to my PC and IMatch picks if up after a few seconds.

Must be something peculiar on your system or something...?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Was iMatch running or closed while you did the changes to the OD folder?

Mario

Running. But I also tried it when it is closed. Since the folder timestamp is changed by OD, IMatch will see the folder as changed and rescan it.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Argh, second mistake today.
I found the relevant topic in the iMatch help file. See the attachment.

I reset "background indexing" to "automatic" and now it seems to work.
No idea, why i changed that to "off". Don't even know when i did it.

Thanks for helping.
Ben

Mario

That explains that. Good good to hear that you solved it.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook