Task #1887
closedThe problem of ndnputfile and ndngetfile
100%
Description
There are some problems both in the design and implementation of these tools.
- repo cannot use ndngetfile to get the data which is inserted by ndnputfile with -s.
When we use ndnputfile -s, the tool will automatically and randomly append a version number after the prefix.
When we want to use ndngetfile, we can decide to use only the prefix or use the prefix with version number to request data (for parameter, with -u means the name contain the version number, without -u means the name we use is only a prefix). Both these two mode cannot be used to get the data back.
1) if without -u, the tool assumes that the data received should include version number as the second to last component and sequence number as last component. But as mentioned above, if we use ndnputfile -s to insert the data, no sequence number will be appended. In this case, repo will throw an error due to the name size does not match, even if the correct data has been pushed back.
2) if with -u, the ndngetfile tool will append a sequence number for interest name (prefix + version + sequence), which cannot be recognized by the repo who have the data. In current repo storage, data names are in the format: prefix + (version) + (sequence) + digest. Since the data inserted by ndnputfile -s, there is no sequence in data name, therefore repo cannot use Name::isPrefixOf to match the correct data.
- We cannot use ndnputfile without -s to insert small data, which could be stored in only one data packet.
In most cases, we should specify -s when we want to insert small data and the data will be stored in one data packet. But in some cases, if we forget to specify -s, repo should also work well by using segment insertion, even if only one segment carries data. However, current ndnputfile cannot make it. Since by using segment insertion, the finalblockId will be specified as %00. WriteHandle needs to use Component::toSegment to decode it from a name component. But this function will throw an error: "Invalid length for nonNegativeInteger (only 1, 2, 4, and 8 are allowed)" and stop the process. Therefore either the toSegment function or the finalBlockId needs to be improved.