isPrivate : missing field

Hello,

I am working at implementing the safe app API in rust, so far I can auth, de-auth, create, read, delete directories, and create, delete files. ( I am quite happy with this yet ! )

I hit something weird , though

when I create a file in a directory, say “testfile.txt” in “/dirtest”, it seems the ‘isPrivate’ field is not written.

After successfully creating the file, if I read the “/dirtest” directory, my rust app panicks and complain about missing isPrivate field.

I triple checked, though, that I DO write this field :

App: Begin creating file…
create_file_data = CreateFileData { filePath: “/dirtest/testfile.txt”, isPrivate: true, metadata: “”, isVersioned: false, isPathShared: false }
App: CreateFile encoded
200 OK …File was created

App: GetDir Response JSON: “{“info”:{“name”:“dirtest”,“isPrivate”:true,“isVersioned”:false,“createdOn”:1459530484879,“modifiedOn”:1459533655710,“metadata”:”"},“files”:[{“name”:“testfile.txt”,“size”:0,“createdOn”:1459533655710,“modifiedOn”:1459533655710,“metadata”:""}],“subDirectories”:[]}"
thread ‘’ panicked at ‘MissingFieldError(“isPrivate”)’, safestuff.rs:435

line 435 is when I try to decode the json into my homebrew object :
let get_dir_response: GetDirResponseData = rustc_serialize::json::decode(&decrypted_response_json_str)
.unwrap_or_else(|e| panic!("{:?}", e));

any idea ?

2 Likes

Can you link any code and/or make a very small reproducible test case? Does somehow your JSON struct think there is supposed to be isPrivate on the file? The isPrivate is passed in to create file so that the system knows if the path is private, isPrivate is not a property of files. This seems to be an issue between your unmarshaller and your struct.

oooh now that makes sense .
the structure where I put my JSON into does think there should be such a field , because I told it so.

but… I shouldn’t ! :slight_smile:

I just edited my code and now it works

Thank you for the lighting !

I will gladly link the code when it is a bit less rough

1 Like

this proves that I do not understand the private concept very well :

the directory is encrypted, not the files. Ok .

“isPrivate : Indicates whether the directory created is private (encrypted) or available for public reads through unauthorised access.”

does this mean that if isPrivate is FALSE, another app can read the contents of the directory ? who does “public reads” relate to, here ?

Likewise, I am not very sure I understand “isPathShared” very well , the doc says : “isPathShared: If
the path is shared then the directory is created within the SAFE Drive or else the directory will be created in the application’s root directory.”

What is the “SAFE Drive” ? is this the user’s directory, that is tied to the 3 credentials given to the launcher ?

I really need to get those 2 concepts precisely before I can pretend to use this stuff !

Yup, I have mentioned that this area is underdocumented (ref: [ANN] SafeClient JS Client Library). I recommend making a JIRA issue asking them to make the distinctions between public/private and shared/non-shared explicitly clear. The files are encrypted too. If isPrivate is false, anyone can read it. isPathShared means that it can be used across apps.

1 Like