Category Archives: auto-update

Apache Commons FileUtils copy owerwriting

I'm trying here to come up with ftp based auto-update solution using Apache commons. The plan was to download all to separate foder and then run separate jar program that moves the content to the root folder.

But by trial and error I found that when using this:

         File actStuff = new File( rootDirLocal );           
         File downStuff = new File( rootDirLocal + "/fromFTP");

            FileUtils.copyDirectory(downStuff, actStuff);



        File actUpd = new File( rootDirLocal + "/my_app.jar");

        if (actUpd.exists())
            Runtime.getRuntime().exec("java -jar " + actUpd.getAbsolutePath());
        } else msg("Updated application not found.");

        } works for some reason. The currently running application gets over-written (during that copyDirectory command) and when I run it by exec function, the new downloaded application starts. How is that possible? Isn't there supposed to be a Windows lock on that file? I can't delete it, I can't move the same file over it, but when I copy it ower, it gets successfully overwritten.

Can I trust this? (I need the app to be working on Windows and Mac.)


Download only diff from a file

I'm working a updater program. This program should check if current program version installed on machine and if so, download the most recent. I'm doing some research about that and I read somewhere that I should download only the file diff to avoid use of user's bandwidth. But how could I do that? how to request only the diff of file x from server? if matter, the server where the file will be hosted on is Apache using PHP.