By Wayne Brill
Issue
I am trying to get the Local file status of a Vault file and in Vault Explorer I can see that the file is downloaded (white circle), and when I right click Go to working folder, I correctly go to the specified file. But when testing through the new API “GetLocalFileStatus”, it returns: InVaultButNotOnDisk.
After some investigation I find that GetEnforceWorkingFolder is true and both GetRequiredWorkingFolderLocation and GetWorkingFolder return "C:\users\<user name>\documents\Vault". This folder path does not match the local path for my Vault file! Is the API call looking in the wrong location?
Solution
In the Vault 2012 API GetWorkingFolder, GetLocalFileStatus and DownloadFile from IExplorerUtil class only work if you are using the default working folder. Once the enforced working folder is set, the working folder information is immediately changed at Vault server side, but it is not reflected in Vault Explorer window until you log out and log in Vault again. All those APIs above mentioned are extracting information from server instead of Vault Client, so you see an unexpected result if you don’t log in Vault Explorer a second time.
In order to compare local file and vault file, you can try a workaround explained as below:
You can use checksums. Get the checksum of the local file. Next call FindFilesByPathsAndChecksums to grab the File object from the server.
If the File object has matching VerNum and MaxCkInVerNum, then the file on disk is up to date.
If the VerNum and MaxCkInVerNum do not match, then the file on disk is out of date.
If you get a File with -1 as the ID, it means that no match was found. Therefore the file on disk does not match any of the versions in the Vault. Call FindLatestFilesByPaths to get the File object from the Vault. If the object shows that the file is checked out to the corresponding computer and local folder, then it’s probably safe to assume that the file on disk is newer than what is in the Vault. If the object does not indicate that the file is checked out, then somebody edited the file without checking it out first and it's impossible to tell if the file is newer or not.
This blog post has an example for CheckSum.