diff options
-rw-r--r-- | util/datamanager.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua index 630353a9..6759592a 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -32,6 +32,7 @@ local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package. local prosody = prosody; +local blocksize = 0x1000; local raw_mkdir = lfs.mkdir; local atomic_append; local remove_blocks; @@ -244,6 +245,12 @@ local function append(username, host, datastore, ext, data) end local pos = f:seek("end"); + if (blocksize-(pos%blocksize)) < (#data%blocksize) then + -- pad to blocksize with newlines so that the next item is both on a new + -- block and a new line + atomic_append(f, ("\n"):rep(blocksize-(pos%blocksize))); + pos = f:seek("end"); + end local ok, msg = atomic_append(f, data); |