Hello, I’m still reading some code, and this is my second question, regarding FilesContainer
, in sn_api/src/api/app/files.rs
. In particular, the function files_container_create
has this comment:
The FilesContainer is created as a Sequence with a single entry containing the timestamp as the entry’s key, and the serialised FilesMap as the entry’s value
Similarly, in append_version_to_files_container
, it says
The FilesContainer is updated by adding an entry containing the timestamp as the entry’s key, and the serialised new version of the FilesMap as the entry’s value
I’m trying to see where and how this timestamp is actually created/stored, but from the high level code, it looks like only the serialized FilesMap is stored.
One possibility is that this timestamp as the “entry key” is a general property of Sequence, so perhaps it’s set up automatically, and I just haven’t dug deep enough to see it. Or, perhaps this is an outdated comment? Also a possibility. So being a newbie, I guess it’s better to just ask the question?
I know there’s a notion of “versions” in a sequence, but I assume this aforementioned “timestamp” is referring to an actual timestamp, right?
For reference, here’s code that I was talking about:
pub async fn files_container_create(
&mut self,
location: Option<&str>,
dest: Option<&str>,
recursive: bool,
follow_links: bool,
dry_run: bool,
) -> Result<(XorUrl, ProcessedFiles, FilesMap)> {
// TODO: Enable source for funds / ownership
// Warn about ownership?
// Let's upload the files and generate the list of local files paths
let (processed_files, files_map) = match location {
Some(path) => {
let mut processed_files =
file_system_dir_walk(self, path, recursive, follow_links, dry_run).await?;
// The FilesContainer is created as a Sequence with a single entry containing the
// timestamp as the entry's key, and the serialised FilesMap as the entry's value
// TODO: use RDF format
let files_map = files_map_create(
self,
&mut processed_files,
path,
dest,
follow_links,
dry_run,
)
.await?;
(processed_files, files_map)
}
None => (ProcessedFiles::default(), FilesMap::default()),
};
let xorurl = if dry_run {
"".to_string()
} else {
let serialised_files_map = serde_json::to_string(&files_map).map_err(|err| {
Error::Unexpected(format!(
"Couldn't serialise the FilesMap generated: {:?}",
err
))
})?;
// Store the FilesContainer in a Public Sequence
let xorname = self
.safe_client
.store_sequence(
serialised_files_map.as_bytes(),
None,
FILES_CONTAINER_TYPE_TAG,
None,
false,
)
.await?;
XorUrlEncoder::encode_sequence_data(
xorname,
FILES_CONTAINER_TYPE_TAG,
SafeContentType::FilesContainer,
self.xorurl_base,
false,
)?
};
Ok((xorurl, processed_files, files_map))
}