luwak_file:create does not truncate file content?

vuleetu vuleetu at gmail.com
Mon Sep 26 01:04:53 EDT 2011


Hi,

   When i tried to use

   {ok, File} = luwak_file:create(Riak, <<"file1">>, dict:new()),
   Size = luwak_file:length(Riak, File),
   io:format("Size is ~p bytes~n", [Size]),
   {ok, _, File1} = luwak_io:put_range(Riak, File, 0, <<"1234567890">>),
   Size1 = luwak_file:length(Riak, File1),
   io:format("Size is ~p bytes~n", [Size1]),
   %%create this file again
   {ok, File2} = luwak_file:create(Riak, <<"file1">>, dict:new()),
   Size2 = luwak_file:length(Riak, File2),
   io:format("Size is ~p bytes~n", [Size2]),
   %%write data at pos 100 which is invalid offset, but it works, why?
   {ok, _, File3} = luwak_io:put_range(Riak, File2, 100, <<"abcdefg">>),
   Size3 = luwak_file:length(Riak, File3),
   io:format("Size is ~p bytes~n", [Size3]).


result:
  Size is 0 bytes
  Size is 10 bytes
  Size is 10 bytes
  Size is 107 bytes
  ok


I tried many times and found seems like as long as i did these operation
using the same Riak connection, it will show results above. but when i used
another Riak connection({ok, Riak} = riak:client_connect('riak at 127.0.0.1').
), it will truncate file contents. Is this the supposed result?

Best regards
Fisher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110926/f74dd822/attachment.html>


More information about the riak-users mailing list