Git Product home page Git Product logo

Comments (9)

ldo avatar ldo commented on September 2, 2024 1

Actually, let me amend that. It should be easier to implement a tell method than I said. Just call lseek with whence = SEEK_CUR and an offset of 0 bytes; this will return the current offset without changing it.

from pysmbc.

marklescroart avatar marklescroart commented on September 2, 2024

Just wanted to gently nudge again on this issue - I don't mean to pester, I know what it's like to support open source code, I'm just hoping to for an answer about whether this might even be possible. Thanks for your time.

from pysmbc.

hamano avatar hamano commented on September 2, 2024

I have no idea to add flush() and tell() with libsmbclient.
https://github.com/samba-team/samba/blob/master/source3/include/libsmbclient.h

If I'm in the same situation as you, I'll transfer the complete file written locally to the remote.

from pysmbc.

marklescroart avatar marklescroart commented on September 2, 2024

OK, thanks for the reply. Uploading whole files is a potential solution, but one I am hoping to avoid for a few reasons. The biggest reason is that the arrays I am hoping to load / save are quite large, so saving to disk and then uploading takes substantially longer than directly uploading, and quickly creates a large cache (e.g. on cluster machines running jobs). But I can work with it. Thanks again for your useful code.

from pysmbc.

ldo avatar ldo commented on September 2, 2024

The obvious answer is to wrap an smbc.File in your own file-like object. Every time write is called, count up the number of bytes written before passing it on. And of course also keep track of seek calls. Then you can implement tell to return the current position.

As for flush, I assume that libsmbclient doesnโ€™t implement buffering. So either implement flush as a noop, or (more complicated) manage your own buffering.

(Duck typing FTW!)

from pysmbc.

frafra avatar frafra commented on September 2, 2024

Workaround:

class SmbcFileWrapper(object):
    def __init__(self, obj):
        self.obj = obj
    def __getattr__(self, name):
        return getattr(self.obj, name)
    def flush(self):
        pass
    def tell(self):
        return self.obj.seek(0, os.SEEK_CUR)

from pysmbc.

frafra avatar frafra commented on September 2, 2024

I added a custom read function to fix another issue: #46 (comment)

from pysmbc.

frafra avatar frafra commented on September 2, 2024

I did 2 pull requests (flush, tell) + a fix for the read function.

Here is a branch with the 3 PR merged together: https://github.com/frafra/pysmbc/tree/nina-fixes

from pysmbc.

frafra avatar frafra commented on September 2, 2024

Upstream bug report for tell: https://bugzilla.samba.org/show_bug.cgi?id=14383
Upstream bug report for flush: https://bugzilla.samba.org/show_bug.cgi?id=14384

from pysmbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.