Recent

Author Topic: [SOLVED] FindAllFiles does not find all files over SMB  (Read 6368 times)

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
[SOLVED] FindAllFiles does not find all files over SMB
« on: February 03, 2013, 04:35:22 pm »
Hi,

when I access a mounted SMB share (shared by Netgear ReadyNas v2) FindAllFiles does not find all files. Linux Filemanager shows all files.
When locally used, all files are found by FindAllFiles.  All files (and dirs) have the same user & permissions.

I am using:

- Lazarus v1.1 on Linux Mint 14
- Lazarus v0.9 on Raspbian (ARM Linux)

both give the same result. On both platform the same 6303 files are found out of the 9200.

I have found one forum entry with the same error, but no solution was suggested.  There have to be more people with the same results.

Code: [Select]
FilesFound:=FindAllFiles(CheckThisDir, '*.mp3;*.flac;*.ogg', True);
« Last Edit: February 04, 2013, 09:22:24 pm by Zittergie »
Be the difference that makes a difference

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: FindAllFiles does not find all files over SMB
« Reply #1 on: February 03, 2013, 04:41:10 pm »
Probably a Samba bug, not an FPC/Lazarus bug, see my response here:
http://lazarus.freepascal.org/index.php/topic,17499.msg113149.html#msg113149
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: FindAllFiles does not find all files over SMB
« Reply #2 on: February 03, 2013, 05:38:19 pm »
Thanks,
Will have to use a workaround :(
Be the difference that makes a difference

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: FindAllFiles does not find all files over SMB
« Reply #3 on: February 03, 2013, 09:08:07 pm »
Code: [Select]
find /mnt/media/Music/ -iname *.mp3 in bash finds all files.

What would be the easiest way to redirect the output to a Stringlist without creating a temp file?
Be the difference that makes a difference

Bart

  • Hero Member
  • *****
  • Posts: 5564
    • Bart en Mariska's Webstek
Re: FindAllFiles does not find all files over SMB
« Reply #4 on: February 03, 2013, 11:23:45 pm »
Known Samba bug, see this issue in fpc bugtracker.

Bart

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: FindAllFiles does not find all files over SMB
« Reply #5 on: February 04, 2013, 09:22:05 am »
@Bart: yes, that's what I told him and he indicated he understood that.

@Zittergie: some variation of the code on e.g. http://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output may be handy.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
SOLVED - Re: FindAllFiles does not find all files over SMB
« Reply #6 on: February 04, 2013, 09:20:58 pm »
Thanks BigChimp.

This is what I came up with, following the link in your reply:
Only Linux  - Will need to check if the error also exists on Windows.

Code: [Select]
for i:=1 to FormConfig.CLB_AddRemote.Items.Count do
    begin
      // When no NAS bug
      if not Formconfig.CB_NasBug.Checked then
      begin
        if FormConfig.CLB_AddRemote.Checked[i-1] then
        begin
          CheckThisDir:= FormConfig.CLB_AddRemote.Items[i-1];
          FormAbout.Memo1.Lines.Add('Checking Folder '+CheckThisDir+' for music');
          FilesFound:=FindAllFiles(CheckThisDir, '*.mp3;*.flac;*.ogg', True);
          Form1.ListAll.Items.AddStrings(FilesFound);
        end;
      end
      else
      // When NAS BUG
      begin
         CheckThisDir:= FormConfig.CLB_AddRemote.Items[i-1];
         FormAbout.Memo1.Lines.Add('Checking Folder '+CheckThisDir+' for music');

        MemStream := TMemoryStream.Create;
        BytesRead := 0;

        OurProcess := TProcess.Create(nil);
        OurProcess.CommandLine := 'find '+CheckThisDir+' -iname *.ogg -o -iname *.flac -o -iname *.mp3';
        OurProcess.Options := [poUsePipes];
        OurProcess.Execute;

        while OurProcess.Running do
        begin
          MemStream.SetSize(BytesRead + READ_BYTES);
          NumBytes := OurProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
          if NumBytes > 0 then Inc(BytesRead, NumBytes)
                          else Sleep(100);
        end;
        repeat
          MemStream.SetSize(BytesRead + READ_BYTES);
          NumBytes := OurProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
          if NumBytes > 0 then Inc(BytesRead, NumBytes);
        until NumBytes <= 0;
        if BytesRead > 0 then WriteLn;
        MemStream.SetSize(BytesRead);

        FilesFound.LoadFromStream(Memstream);
        Form1.ListAll.Items.AddStrings(FilesFound);

        OurProcess.Free;
        MemStream.Free;
      end;
    end;                           
Be the difference that makes a difference

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: [SOLVED] FindAllFiles does not find all files over SMB
« Reply #7 on: June 03, 2013, 10:38:36 pm »
Found another weird problem with FindAllFiles() after upgrading MacOS to 10.8.3
A network folder 'inxs' containing 1 file is found 2 times, once as 'inxs' and once as 'INXS'.  %)

Was working like it should be on 10.6
Be the difference that makes a difference

 

TinyPortal © 2005-2018