util.datamanager: Add some comments about the append function
authorKim Alvefur <zash@zash.se>
Fri, 11 Dec 2015 19:29:55 +0000 (20:29 +0100)
committerKim Alvefur <zash@zash.se>
Fri, 11 Dec 2015 19:29:55 +0000 (20:29 +0100)
util/datamanager.lua

index ce4c5b5a22722270fb4fa86aecf478d3359248b9..510c0161aca948f6a0546ebb2cc8d7b1929a5b8d 100644 (file)
@@ -209,17 +209,20 @@ local function store(username, host, datastore, data)
        return true;
 end
 
+-- Append a blob of data to a file
 local function append(username, host, datastore, ext, data)
        local filename = getpath(username, host, datastore, ext, true);
 
        local ok;
        local f, msg = io_open(filename, "r+");
        if not f then
+               -- File did probably not exist, let's create it
                f, msg = io_open(filename, "w");
                if not f then
                        return nil, msg;
                end
        end
+
        local pos = f:seek("end");
        ok, msg = fallocate(f, pos, #data);
        if not ok then