Azelphur / ownCloud-share-tools

A tool to enable easy sharing of ownCloud files from your desktop, also a Python library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linux the directory ~/.local/share/data/ownCloud/folders/ is empty

nalipaz opened this issue · comments

I keep getting the error:

This file is not in an ownCloud share.

I investigated the code and it is looping through the directory ~/.local/share/data/ownCloud/folders/ checking for config files I think. However, for me that directory is always empty. Perhaps something changed with the ownCloud client and it no longer stores data there. I did see that the list of directories synchronized in the owncloud client are stored in ~/.local/share/data/ownCloud/owncloud.cfg. My file looks like:

[General]
optionalDesktopNotifications=true
monoIcons=false
crashReporter=true
newBigFolderSizeLimit=500
useNewBigFolderSizeLimit=true

[Accounts]
version=2
0\url=https://server-address/owncloud
0\http_certificatePasswd=
0\http_certificatePath=
0\http_user=nalipaz
0\authType=http
0\user=nalipaz
0\General\CaCertificates="@ByteArray(-----BEGIN CERTIFICATE-----[...censored...]\n-----END CERTIFICATE-----\n\n)"
0\serverVersion=9.0.2.2
0\Folders\1\localPath=/home/nalipaz/ownCloud/
0\Folders\1\targetPath=/
0\Folders\1\paused=false
0\Folders\1\ignoreHiddenFiles=true

[ActivityListHeader]
geometry=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2\x8b\0\0\0\x5\x1\0\0\x1\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\x4\0\0\0\x64\0\0\0\x1\0\0\0\0\0\0\0\xb4\0\0\0\x1\0\0\0\0\0\0\0\xc8\0\0\0\x2\0\0\0\0\0\0\0\xab\0\0\0\x1\0\0\0\0)

[Settings]
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x1\0\0\0\0\x2\x64\0\0\x1-\0\0\x5\x1a\0\0\x3\x7f\0\0\x2\x65\0\0\x1\x41\0\0\x5\x19\0\0\x3~\0\0\0\0\0\0)

I am on Debian Jessie with the latest owncloud desktop client:

$ owncloud --version
ownCloud version 2.2.3
Using Qt 4.8.6

On another note, with the lack of activity on this project I am also wondering if it is dead?

I worked with the ownCloud team to build this functionality into the client, so there's not much point to this project now as the standard client does pretty much everything this does, and more :)

Interesting, I did read that integration issue on the owncloud issue queue, however I didn't find any options on my OS for owncloud. I am using Thunar and Debian and have installed owncloud client as per the instructions on their site. It seems I am on the latest version. I guess I might have to take it up with them if I can't figure out how to get the options to show up in Thunar.

Amusingly I used to use Thunar, and while Thunar isn't officially supported, I did hack something up to call ownClouds builtin thing from a Thunar custom action

#!/usr/bin/python

import os
import urllib
import socket
import sys

from gi.repository import GObject

appname = 'ownCloud'


def get_runtime_dir():
    """Returns the value of $XDG_RUNTIME_DIR, a directory path.

    If the value is not set, returns the same default as in Qt5
    """
    try:
        return os.environ['XDG_RUNTIME_DIR']
    except KeyError:
        fallback = '/tmp/runtime-' + os.environ['USER']
        return fallback


class SocketConnect(GObject.GObject):
    def __init__(self):
        GObject.GObject.__init__(self)
        self.connected = False
        self.registered_paths = {}
        self._watch_id = 0
        self._sock = None
        self._listeners = [self._update_registered_paths]
        self._remainder = ''
        self.nautilusVFSFile_table = {} # not needed in this object actually but shared 
                                        # all over the other objects.

        # returns true when one should try again!
        if self._connectToSocketServer():
            GObject.timeout_add(5000, self._connectToSocketServer)

    def reconnect(self):
        self._sock.close()
        self.connected = False
        GObject.source_remove(self._watch_id)
        GObject.timeout_add(5000, self._connectToSocketServer)

    def sendCommand(self, cmd):
        if self.connected:
            try:
                self._sock.send(cmd)
            except:
                print("Sending failed.")
                self.reconnect()
        else:
            print("Cannot send, not connected!")

    def addListener(self, listener):
        self._listeners.append(listener)

    def _connectToSocketServer(self):
        try:
            self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            postfix = "/"+appname+"/socket"
            sock_file = get_runtime_dir()+postfix
            print ("Socket: " + sock_file + " <=> " + postfix)
            if sock_file != postfix:
                try:
                    print("Socket File: "+sock_file)
                    self._sock.connect(sock_file)
                    self.connected = True
                    print("Setting connected to %r" % self.connected )
                    self._watch_id = GObject.io_add_watch(self._sock, GObject.IO_IN, self._handle_notify)
                    print("Socket watch id: "+str(self._watch_id))
                    return False # don't run again
                except Exception as e:
                    print("Could not connect to unix socket." + str(e))
            else:
                print("Sock-File not valid: "+sock_file)
        except Exception as e:
            print("Connect could not be established, try again later ")
            print(e)
            self._sock.close()

        return True # run again, if enabled via timeout_add()

    # notify is the raw answer from the socket
    def _handle_notify(self, source, condition):
        data = source.recv(1024)
        # prepend the remaining data from last call
        if len(self._remainder) > 0:
            data = self._remainder+data
            self._remainder = ''

        if len(data) > 0:
            # remember the remainder for next round
            lastNL = data.rfind('\n');
            if lastNL > -1 and lastNL < len(data):
                self._remainder = data[lastNL+1:]
                data = data[:lastNL]

            for l in data.split('\n'):
                self._handle_server_response(l)
        else:
            return False

        return True # run again

    def _handle_server_response(self, line):
        print("Server response: "+line)
        parts = line.split(':')
        action = parts[0]
        args = parts[1:]

        for listener in self._listeners:
            listener(action, args)

    def _update_registered_paths(self, action, args):
        if action == 'REGISTER_PATH':
            self.registered_paths[args[0]] = 1
        elif action == 'UNREGISTER_PATH':
            del self.registered_paths[args[0]]

            # Check if there are no paths left. If so, its usual
            # that mirall went away. Try reconnecting.
            if not self.registered_paths:
                self.reconnect()

socketConnect = SocketConnect()
socketConnect.sendCommand("SHARE:"+sys.argv[1]+"\n")

Try this bit of Python code, it takes one argument, the full path to the file to share.
You can add it as a custom action in Thunar with owncloud-thunar %F

wow, that works beautifully!

You should really post that as a project so others can easily integrate into Thunar. Thanks for all your hard work and responsiveness on this stuff!