* Check for Unlinked Media

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Check for Unlinked Media

Post by gerrynuk » 15 Oct 2012 12:27

Jane said:
Strange,  that's just returning from the file list of the item is a file or a directory.  Do you have any symbolic links in your media folder?

Any chance you can add a print at line 55 so you get and try running the plugin from the editor  

print(filename)
if attr.mode == 'file' then

and see if there is any thing different about the file it stops on.
Jane,

Sorry but I have only just found time to re-test the plugin. I downloaded the latest version (1.5) but still get an error message when I click on List Unlinked media:

Image

As you have updated the plugin since my first post is it still possible to run the test you describe?

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check for Unlinked Media

Post by tatewise » 15 Oct 2012 13:07

Yes, but the line number is now 84.
Alternatively, use Edit > Find > if attr.mode == 'file' then.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Check for Unlinked Media

Post by gerrynuk » 18 Oct 2012 11:59

Hi Mike & Jane,

I added the extra statement at line 84 and ran the plugin from the editor. I got this result:

Image

It seems to be indexing the media but then fails.

Gerry

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check for Unlinked Media

Post by tatewise » 18 Oct 2012 12:54

Continuing the sequence of files being indexed, what would be the next folder/file likely to follow ...mediaBMBmarriages.picasaoriginalsxx George Robinson...?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Check for Unlinked Media

Post by gerrynuk » 18 Oct 2012 16:56

tatewise said:
Continuing the sequence of files being indexed, what would be the next folder/file likely to follow ...mediaBMBmarriages.picasaoriginalsxx George Robinson...?
Mike,

With your help I have tracked down the problem which is that some of the media have characters that Windows machines don't like - such as '/' and quotes. Having eliminated these the plugin now works perfectly. My media is stored on an iMac which is much more tolerant of these characters.

Many thanks,

Gerry

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check for Unlinked Media

Post by tatewise » 18 Oct 2012 17:44

Note to Jane!
I wonder is it possible to trap the nil value for attr, perhaps inside dirtree(), so that the problem can be reported more elegantly?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Check for Unlinked Media

Post by Jane » 18 Oct 2012 19:10

V1.5 which is in the plugin store now uses

Code: Select all

  if type(attr) == 'table' then
     if attr.mode == 'file' then
        local strlc = string.lower(filename:gsub(rootpattern..'\',''))
        filelist[strlc] = filename
     end
  end
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check for Unlinked Media

Post by tatewise » 18 Oct 2012 20:30

That is the version we are using Jane.
The problem is that it fails on line 82 for filename,attr in dirtree(mediafolder) do before it gets to the 'table' test.

May I suggest in dirtree

Code: Select all

    local function yieldtree(dir)
        for entry in lfs.dir(dir) do
            if entry ~= '.' and entry ~= '..' then
                entry=dir..'\'..entry
                local attr,error=lfs.attributes(entry)
                if attr == nil then print(error) end
                coroutine.yield(entry,attr)
                if attr.mode == 'directory' then
                    yieldtree(entry)
                end
            end
        end
    end
Although the if attr == nil then... could be more sophisticated and added to the Directory Tree (code snippet).

Gerry ~ could you try that change by replacing:
local attr=lfs.attributes(entry)
with
local attr,error=lfs.attributes(entry)
if attr == nil then print(error) end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Check for Unlinked Media

Post by Jane » 19 Oct 2012 09:09

Mike I wonder if this might be better

Code: Select all

   local function yieldtree(dir) 
       for entry in lfs.dir(dir) do 
           if entry ~= '.' and entry ~= '..' then 
               entry=dir..'\'..entry 
               local attr,error=lfs.attributes(entry) 
               if attr == nil then attr = {mode='attrfail',error=error} end 
               coroutine.yield(entry,attr) 
               if attr.mode == 'directory' then 
                   yieldtree(entry) 
               end 
           end 
       end 
   end 
That way mode could be checked in the returned data and trapped if needed, rather than the whole traverse failing.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 27087
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check for Unlinked Media

Post by tatewise » 19 Oct 2012 09:22

Yes, that looks a neat solution.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply