Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd FileManagerThread #11029
Add FileManagerThread #11029
Conversation
highfive
commented
May 5, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 5, 2016
|
@Manishearth. |
| .and_then(|systime| systime.elapsed().map_err(|_| ())) | ||
| .and_then(|elapsed| Ok(elapsed.as_secs())); | ||
|
|
||
| let filename = path.file_name().and_then(|filename| filename.to_str()) |
This comment has been minimized.
This comment has been minimized.
Manishearth
May 5, 2016
Member
We should probably store this as a path, filenames aren't necessarily utf8.
This comment has been minimized.
This comment has been minimized.
izgzhen
May 6, 2016
Author
Contributor
The problem is that both Path and OsStr don't implement the Serialize trait.
This comment has been minimized.
This comment has been minimized.
Manishearth
May 6, 2016
Member
PathBuf has an impl. Path/OsStr are slices.
If that doesn't work, just use a byte vector and work on getting an impl upstream in serde.
This comment has been minimized.
This comment has been minimized.
izgzhen
May 6, 2016
Author
Contributor
OK, I will see if I can make OsString and PathBuf serializable in upstream.
| }; | ||
| } | ||
|
|
||
| fn read_file(&mut self, sender: IpcSender<FileManagerResult<Vec<u8>>>, id: Uuid) { |
This comment has been minimized.
This comment has been minimized.
Manishearth
May 5, 2016
Member
This should probably send chunks. Not necessary right now, but eventually.
|
LGTM with the path change. |
highfive
commented
May 5, 2016
|
New code was committed to pull request. |
highfive
commented
May 6, 2016
|
New code was committed to pull request. |
highfive
commented
May 6, 2016
|
New code was committed to pull request. |
highfive
commented
May 6, 2016
|
New code was committed to pull request. |
highfive
commented
May 8, 2016
|
New code was committed to pull request. |
|
|
||
| pub struct FileManager { | ||
| receiver: IpcReceiver<FileManagerThreadMsg>, | ||
| idmap: RefCell<HashMap<Uuid, String>>, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
izgzhen
May 11, 2016
Author
Contributor
Currently, the libnfd returns a String in this way: CString::from_raw(*out_path).into_string(). Maybe there is encoding checking stuff. I will take a look at this.
This comment has been minimized.
This comment has been minimized.
Manishearth
May 11, 2016
Member
I suspect we should convert from CString to OSString to Path directly.
This comment has been minimized.
This comment has been minimized.
izgzhen
May 11, 2016
Author
Contributor
Looks like a vital piece of conversion is missing: https://doc.servo.org/src/std/up/src/libstd/ffi/os_str.rs.html#59
| impl FileManager { | ||
| fn select(&mut self, sender: SelectedPort) { | ||
| // TODO: Pull the dialog UI in and get selected | ||
| match sender { |
This comment has been minimized.
This comment has been minimized.
Manishearth
May 11, 2016
Member
I sort of feel that this would be better as two functions with no SelectedPort, and have the dialog code take an argument specifying single or multiple.
This comment has been minimized.
This comment has been minimized.
| self.idmap.borrow_mut().insert(id, file_path.to_string()); | ||
|
|
||
| // Unix Epoch: https://doc.servo.org/std/time/constant.UNIX_EPOCH.html | ||
| let epoch = handler.metadata().and_then(|metadata| metadata.modified()).map_err(|_| ()) |
This comment has been minimized.
This comment has been minimized.
Manishearth
May 11, 2016
Member
probably should leave a note about mtime vs ctime, iirc we haven't made that decision yet
| } | ||
| } | ||
|
|
||
| fn create_entry(&mut self, file_path: &str) -> Option<(Uuid, PathBuf, u64)> { |
This comment has been minimized.
This comment has been minimized.
| }; | ||
| } | ||
|
|
||
| fn delete_fileid(&mut self, id: Uuid) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
izgzhen
May 11, 2016
Author
Contributor
I thought about this name before as well, and I doubt if this name is kind of misleading?
This comment has been minimized.
This comment has been minimized.
Manishearth
May 11, 2016
Member
Nah, just consistency. This isn't really important, so feel free to keep it as is if you like this name.
highfive
commented
May 11, 2016
|
New code was committed to pull request. |
|
@bors r+ |
|
@bors-servo r=Manishearth |
|
|
Add FileManagerThread This is intended to support the File API implementation. Basically an event loop with three kinds of messages: + Select a file + Read a file with ID + Delete the ID from manager-owned map The design decision in this PR is not the final (or best I think) version, welcome reviews :) TODOs: - [x] Add multiple file selection <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11029) <!-- Reviewable:end -->
|
|
|
Ping issue #11131 |
izgzhen commentedMay 5, 2016
•
edited
This is intended to support the File API implementation. Basically an event loop with three kinds of messages:
The design decision in this PR is not the final (or best I think) version, welcome reviews :)
TODOs:
This change is