• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Bug: catalog methods don't ignore case on Windows

LEGEND ,
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

The methods catalog:addPhoto () and catalog:findPhotoByPath () don't ignore case on WIndows 7 32-bit.  If you invoke catalog:addPhoto () twice on the same path but using different case, LR 3 gets very confused, importing the photo a second time and adding a second C hierarchy to the Folders panel:

Capture.PNG

In the parent forum, there are a number of posts observing that LR has added duplicated drive or folder entries, and some of them mention that the folders have different case.

Here's code illustrating the problem.  Beware that this could corrupt the catalog, so invoke it in a test catalog only:

local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local catalog = import 'LrApplication'.activeCatalog ()

LrTasks.startAsyncTask (function ()
    catalog:withWriteAccessDo ("Test add photo", function (context)
        local path = []
        local photo = catalog:addPhoto (path)
        LrDialogs.message ("Path: " .. photo:getRawMetadata ("path"))
        LrDialogs.message ("Found by original case: " ..
            tostring (catalog:findPhotoByPath (path)))
        LrDialogs.message ("Found by lower case: " ..
            tostring (catalog:findPhotoByPath (string.lower (path))))
        local photo = catalog:addPhoto (string.lower (path))
        LrDialogs.message ("Path: " .. photo:getRawMetadata ("path"))
        end)
    end)

TOPICS
SDK

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

I believe it - I've had to do a lot of case handling finagling in my plugins - catalog is case sensitive, although disk files are not (in Windows). Lightroom doesn't pay much attention to the distinction, so you (and I) must - at least for the time being...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2010 Jul 07, 2010

Copy link to clipboard

Copied

It seems like a basic design misfeature in the catalog (independent of the SDK), and it's biting users, as evidenced by the posts in the parent forum.  I believe both Mac (by default) and Windows (always) ignore case when comparing paths.

To cope, I guess we need to pretend that the following invariants are true:

- The path recorded in the catalog has the same case as recorded in the file system.

- Users and other tools won't change the case of paths by renaming a file.

- The OS always reports the same case for a path (not true in Windows for network shares).

Then, to accept as input paths from other tools or directly typed by users that may have case different than what's in the catalog, there should be a utility function that takes the path of an existing file and normalizes it to the case currently recorded in the file system.  Looking at LrFileUtils, there's a slow way of doing that, using directoryEntries() to normalize the case of directories in the path starting at the root; but that will require platform-dependent parsing of the path components.

Absent such a utility function, a plugin should never accept paths input by the user or another tool except via LrDialogs.runOpenPanel().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2010 Sep 28, 2010

Copy link to clipboard

Copied

LATEST

I have a few cases where I want to compute a filename from another filename, then check if its in the catalog. If the computed filename may match a disk file but not be found in the catalog due to a case mismatch, I use this function to get the exact filename:

function RcFileUtils.getExactPath( _path )
    local dir = LrPathUtils.parent( _path )
    local path = LrStringUtils.lower( _path )
    for filePath in LrFileUtils.files( dir ) do
        local path2 = LrStringUtils.lower( filePath )
        if path == path2 then
            return filePath
        end
    end
    return nil
end

Obsiously, for performance reasons, its best to use this sparingly.

This makes sure the path being used is exactly what's on disk. And, to protect against the possibility that the case of the disk file has been changed since it was added to the catalog, there is:

function RcCatalog.getPhotoByPathIgnoringExtCase( path )
    local photo = catalog:findPhotoByPath( path )
    if photo then
        return photo
    else
        local ext = LrPathUtils.extension( path )
        if ext == nil then return nil end
        ext = LrStringUtils.upper( ext )
        local _path = LrPathUtils.replaceExtension( path, ext  )
        photo = catalog:findPhotoByPath( _path )
        if photo then
            return photo
        else
            ext = LrStringUtils.lower( ext )
            _path = LrPathUtils.replaceExtension( path, ext  )
            photo = catalog:findPhotoByPath( _path )
            if photo then
                return photo
            end
        end
    end
    return nil
end

This particular function only checks the case of the extension (since that's all I needed to solve the problem at hand), but could be modified to do the whole path in case user (or tool) changed case of any part.

It doesn't check every permutation either - just as-found-on-disk, all upper, and all lower.

+1 vote for case insensitve catalog functions.

Rob

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2010 Sep 14, 2010

Copy link to clipboard

Copied

Here's another place that this is a big problem:  converting a PSE catalog to Lightroom.  Lightroom is failing to convert all 12,000 of my photos because it doesn't see the drive upon which they live (a network share).  It finds:

VOLUME-NAME:

but the PSE catalog, for various reasons, has the files under either

Volume-name:

or

volume-name:

all three of which LR sees as completely independent.  I don't suppose there's a reliable tool for changing the pointer in the PSE catalog...?

G.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2010 Sep 14, 2010

Copy link to clipboard

Copied

Since version 6, PSE has had at least a couple long-standing bugs with the case of share names.  (I reported the bug, but Adobe has fixed very few PSE Organizer bugs since they mangled PSE 6.)  The only way I've found to work around is to get a copy of sqlite3, dump out the database as a text file, edit the text file, and reload the text file (or use SQLite Database Browser, a GUI tool). 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2010 Sep 14, 2010

Copy link to clipboard

Copied

Frankly, I gave up.  As with any exercise like this there is a point of diminishing return.  I was attempting a number of hacks (all just experiments) to fix the share name problem, from renaming the fileserver to moving parts of the catalog out and back, none of which made any difference... and after hours of that stuff I jumped back into the PC version of Lightroom (with a perfectly working catalog in PC PS8, no discernible difference) and the link to upgrade the PSE catalog was gone, and nothing I could do would bring it back.  Lightroom just decided I no longer had one.

So I'm abandoning the PSE8 -> PC Lightroom -> Mac Lightroom plan and currently just importing what I have (with the metadata fixed by your excellent program).  Thanks anyway for all your help.

Sincerely,

G.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2010 Sep 14, 2010

Copy link to clipboard

Copied

and the link to upgrade the PSE catalog was gone, and nothing I could do would bring it back.  Lightroom just decided I no longer had one.

Yeah, a number of people have complained about that in the main forum.  But at least you've got an acceptable path forward.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines