My preliminary testing of the folder:getPhotos function indicated it was working as documented - attending to the "include-children" parameter as expected (and returning all photos in a folder, and subfolders if include-children parameter true. whether filtered or stacked...).
Now, it seems to be ignoring the include-children parameter and returning just the portion of photos that are contributing to the filmstrip, regardless of what I pass for the include-children parameter - its excluding those that are not top of stack, or are being excluded by lib filter...
This latter behavior is exactly what I want, but its really bugging me that I concluded it was working differently before. And of course I fear it will revert to the previous (documented) behavior if I turn my back on it...
Am I losing my mind?
This function is presently working perfectly!? (but it seems like it shouldn't!!!):
UPDATE: *** THIS FUNCTION NO LONGER WORKING (SEE BELOW), OR SHOULD I SAY IS WORKING HOW I EXPECT WHICH IS TO NOT WORK!!!
(my presently conclusion is that folder:getPhotos is flaky - behavior shifts between returning all photos in folder (subject to include-children parameter), and just those contributing to filmstrip, ignoring include-children parameter)
Am I losing my mind?
--- Get list of photos in filmstrip.
--
-- @usage this function *may* not be perfect, and may return photos even if excluded by lib filter or buried in stack.
-- <br> presently its working perfectly, but I don't trust it, and neither should you!?
-- <br> *** originally: function Catalog:getFilmstripPhotos( assumeSubfoldersToo, bottomFeedersToo )
--
-- @return array of photos - may be empty, but never nil (should not throw any errors).
--
function Catalog:getFilmstripPhotos()
--local subfolders
--if assumeSubfoldersToo == nil then
-- subfolders = false -- nil means true otherwise.
--end
local targetPhoto = catalog:getTargetPhoto()
if targetPhoto == nil then
return catalog:getTargetPhotos()
end
local sources = catalog:getActiveSources()
if sources == nil or #sources == 0 then
return {}
end
local photoDict = {} -- lookup
local filmstrip = {} -- array
local function addToDict( photos )
for i, photo in ipairs( photos ) do
--if not bottomFeedersToo then
-- local isBuried = cat:isBuriedInStack( photo )
-- if isBuried then
-- --
-- else
-- photoDict[photo] = true
-- end
--else
photoDict[photo] = true
--end
end
end
local function getPhotosFromSource( source )
if source.getPhotos then
-- local photos = source:getPhotos( subfolders ) -- reminder: nil parameter behaves as true, not false.
local photos = source:getPhotos() -- At the moment, this function is doing exactly what I want: returning the photos as they contribute to filmstrip,
-- and excluding bottom feeders - its ignoring the "include-children" parameter. I could have sworn it was previously attending to said parameter as documented.
-- Although I'm glad it is behaving as it is, I fear problems that go away by themselves will return by themselves. ###3 - good for now I guess...
addToDict( photos ) -- assure no duplication, in case overlapping sources.
return
elseif source.getChildren then
local children = source:getChildren()
for i, child in ipairs( children ) do
getPhotosFromSource( child )
end
elseif source.type then
app:logWarning( "Unrecognized source type: " .. source:type() )
else
app:logWarning( "Unrecognized source: " .. str:to( source ) )
end
end
local sources = catalog:getActiveSources()
--local sc = 0
for i, source in ipairs( sources ) do
--sc = sc + 1
getPhotosFromSource( source )
end
for k, v in pairs( photoDict ) do
filmstrip[#filmstrip + 1] = k
end
return filmstrip
end
Thanks for any light you can shed,
Rob
North America
Europe, Middle East and Africa
Asia Pacific