python-fuse icon indicating copy to clipboard operation
python-fuse copied to clipboard

fh is not passed to read()

Open kidburglar opened this issue 6 years ago • 2 comments

Hello, I try to inspire me from megaFS (it look like it use the same API version that is write in the wiki).

https://github.com/ju1i3nm/MegaFS/blob/master/megafs.py#L83

So I do the same in my code for open()

    def open(self, path, flags):
        # ~ st = fuse.FuseFileInfo()
        # ~ setattr(st, 'direct_io', True)
        # ~ setattr(st, 'nonseekable', True)
        (tmp_f, tmp_path) = tempfile.mkstemp(prefix='syno_')
        os.close(tmp_f)
        if self.fl.get_file(path, mode='download', output=tmp_path):
            return open(tmp_path, "rb")

And I use that for my read()

    def read(self, path, size, offset, fh):
        fh.seek(offset)
        return fh.read(size)

But python is complaining because fh is required argument.

Did I do something wrong, maybe I missed something in the wiki.

Thanks for your help.

kidburglar avatar Sep 01 '19 10:09 kidburglar

Can you provide a minimum code example reproducing your error ?

sdelafond avatar Dec 17 '19 08:12 sdelafond

Hello @sdelafond

Sorry for my late reply.

I can provide the class I'm writing but it's for Synology. I'm not sure it could help you without having one.

The main issue is that python not accept that I pass "fh" in my read arguments. Maybe I not use the good method (it's my first code with Fuse).

kidburglar avatar Dec 21 '19 12:12 kidburglar

the way i see it, read has 3 arguments

    def read(self, path, size, offset):
  • https://github.com/libfuse/python-fuse/blob/fe0c41795cbbbc6de6350f30885c694e8b050f24/example/cups.py#L93

you providing extra parameter of results an error.

so, yes. providing source code would have shown exactly what you were doing in your code. also, you should show your error, that would have left less guess-work here.

glensc avatar Mar 12 '24 15:03 glensc

Hello @glensc

Thanks for your answer. I wrote the code multiple years ago, and it was for a friend that I don't even have any contact with, so I would not be able to test it again.

I will close the issue because there is a big chance I will not come back to it, thanks to remembering me this issue, so I can close it properly.

kidburglar avatar Mar 12 '24 16:03 kidburglar

🚧 Never link to branches, share a permalink 🚧

  • see https://news.ycombinator.com/item?id=8046710 and https://help.github.com/articles/getting-permanent-links-to-files/ and https://docs.gitlab.com/ee/user/shortcuts.html#project-files
  • hit y
  • and perhaps for https://github.com/josephfrazier/octopermalinker (GitHub)

NOTE: edit your post and fix it with a permalink!

glensc avatar Mar 13 '24 08:03 glensc

Hello @glensc

Thanks for your concern and I didn't know it, thanks for letting me know. But I don't appreciate the note, so instead you got the removing of the link because it doesn't alter the fact that I will not try to find my code back.

Cheers

kidburglar avatar Mar 13 '24 09:03 kidburglar

But I don't appreciate the note, so instead you got the removing of the link because it doesn't alter the fact that I will not try to find my code back.

Sorry about the tone of that "note" indeed, and thanks for having taken the time to add extra information to that super old issue: that was much appreciated!

sdelafond avatar Mar 13 '24 10:03 sdelafond