Home > Blog > Programming > GSoC: Copy, Cut, and Paste Shared Files in ownCloud

GSoC: Copy, Cut, and Paste Shared Files in ownCloud

July 13th, 2011

As usual I ran into a couple more issues this past week that prevented me from completing many of the items on my Todo list. I also forgot to finish a couple of things like copying files, because it isn’t part of the web frontend.

First, I’d like to take some time responding to Lukas’s comment to last week’s post. I’ve spent a while debating whether or not to store all file records in the database or continue with the current solution with only recording folders and any files that differ compared to their parent folder. I’ve decided that it is best to stick with current solution because ownCloud isn’t designed nor wants to support a large number of users, but only small groups. Lukas also suggested some additional permissions or rules instead of the current read or write. Well, protected files are what every user has in their own directory. Private files with links are what the public link app can already do using a token for the link. Eventually this will be part of sharing files and offer the same functionality in one interface. Shared files right now are pulled directly out of the owner’s file system, but you have limited power when dealing with those files and can’t physically delete them, only unshare the files from yourself. Creating copies of the files would require a huge rewrite and it doesn’t seem to be worth the effort. If you’re still confused about how sharing files work and where your files are going please continue to ask questions.

Now, this past week figuring out how to copy files took a very long time and revealed many bugs along the way. I was using Dolphin and connected to ownCloud using WebDAV and I tried to copy a file from my shared directory that was actually my dummy user Bob’s file to my own filesystem root. Each time I received a 404 error, which didn’t make sense because ownCloud’s filesystem abstraction makes WebDAV see the same filesystem as the web frontend. I started logging the path translation occuring inside of the file_exists() function in the shared storage provider, and to my suprise the target and source path were the same. Turns out that I made a mistake during some of my previous testing in the database, which resolved the 404 error, but I shouldn’t be getting the same target back with my getSource() function. Yet again I had made another dumb mistake and forgotten to check if a variable was false before returning it as part of a string. This wasn’t the end of the bugs however, I still couldn’t copy files out of my shared directory and I wasn’t getting any errors in Dolphin now. Looking into my web server’s error log I discovered that there was an undefined variable inside of the local storage provider. The problem was a missing argument for the function fromTmpFile(). Now everything works perfectly and the good part is that this will benefit other storage providers because copying was broken when it was between two different storage providers.

I’m a little curious now why my IDE (Eclipse) or anyone else’s IDEs didn’t flag that line. There was clearly a problem because the function had two parameters and only one variable was passed to it. Is there something that I’m missing about PHP support in Eclipse because I thought problems were marked automatically? I like Eclipse because I’ve used it for Android development, but now I’m considering switching to something different that will actually help me out and show me the problems in the code. Does anyone have any IDE suggestions?

Back to my actual project, I now have copying and cutting of files working in and out of the shared directory with permission checks as well. Unfortunately WebDAV doesn’t notify Dolphin about the permissions it has for the files and folders. Usually the paste option in the right-click menu is disabled if I can’t write into a folder, but Dolphin tries to copy files anyways until the permission checks inside of the shared storage kick in and stop the copying. Is there a way to have WebDAV pass on this information and is there a way to have it provide image previews as well? I hope to finally start working on hooks and a basic user interface for sharing files within the web frontend this week. I’ll try my best this week to have a screenshot in the next post and instructions on how to help test!

Categories: Programming Tags: , ,
  1. July 14th, 2011 at 05:15 | #1

    Just my preference as PHP IDE: Netbeans
    The only downside (for me) is that sometimes it can be slow if it scans projects, but that scanning can be switched off.
    And one thing that could be a nice feature, that i think about in the last time when i hear about ownclo├║d: deduplication.

  2. Fabrizio
    July 14th, 2011 at 06:32 | #2

    Your IDE dosen’t flag the line because in PHP every argument passed to a function is considered optional. You can define a function with ten parameters and pass it none, it’s not an error. This works well with default parameter (a parameter which has a default value in its declaration).
    Happy GSoC guys

  3. Thomas M
    July 14th, 2011 at 07:08 | #3

    I’m using netbeans for PHP development. There are a couple of experimental options for error highlighting but I usually have them disabled because there are so many files in a typical typo3 project and it slows things down. (netbeans is quite heavy)

    If you want to give it a try, a couple of tips:
    You can get rid of the ugly Java look by starting netbeans with:
    netbeans –laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel

    if you have a gtk-qt engine installed it should look pretty native on kde.

    If you’re used to vi keybindings, the jVi plugin IMO has the best vi support of any IDE (apart from vim itself)
    With nb 7 there is now also git support, just look for the plugin in the repository.

  4. July 16th, 2011 at 15:07 | #4

    @Fabrizio Thanks for the info, I never realized that.

    @Gunni and @Thomas M I’ve used Netbeans before for Java and it seemed decent. I really need to switch because Eclipse is starting to use one gigabyte of ram for PHP with only a few files open, while if I use Eclipse for Java it only uses around half a gigabyte. I’ll check out Netbeans for PHP though, as for git support I believe Eclipse has plugins for it as well, but I like using the terminal and I’ve learned a lot about git by using the commands.

Comments are closed.