-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63efb50
commit 8673831
Showing
4 changed files
with
136 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
how to get multi file support workin | ||
|
||
1. sender needs to be able to decide which files to send | ||
- /a/path/to/a/directory -> every file and sub directory and sub file... | ||
- /a/path/to/some/files/* -> every file in the directory | ||
|
||
2. sender needs to assign each file an id + tell the receiver what directories need to be created | ||
- probably gotta bite the bullet and use a protobuf here | ||
- directories should probably be constructed by the receiver? | ||
- the receiver needs to have a map of file ids to destination file paths | ||
|
||
struct Message { | ||
inner: MessageType | ||
} | ||
|
||
enum MessageType { | ||
Files { | ||
directories: Vec<&str>, | ||
files: HashMap<u32, (&str, u64)> // file path, file size | ||
}, | ||
Confirmations { | ||
indexes: HashMap<u32, Vec<u64>>, | ||
}, | ||
StartIndex { | ||
id: u32, | ||
index: u64, | ||
}, | ||
Start { | ||
id: u32, | ||
}, | ||
End { | ||
id: u32, // this should be sent by the receiver when the writer exits so the sender can clean up | ||
} | ||
} | ||
|
||
3. the reader needs some changes | ||
- i guess multiple readers will be needed. the id's will need to be added to the packets too | ||
- one queue can be used | ||
- each reader will need its own read semaphore, the control server will need to keep track of them all (cry) | ||
|
||
4. the receiver needs to spawn writers and created queues for each id it receives + create the directories | ||
- should be pretty easy | ||
|
||
5. the control stream is gonna be a bit more complicated now | ||
- should probably communicate in protobufs | ||
- needs to control the sender and receiver exiting. if the stream breaks it can exit both ends | ||
- we really don't need to care about the reader or writer's results/completion unless they are Err | ||
|
||
|
||
things to think about | ||
- probably need a system to limit the number of concurrent files | ||
this will include sending the ids to the receiver as they are started | ||
so writers and queues are only created when needed | ||
readers and send queues should be considered too ig | ||
- i guess every time a new file gets started there needs to be a little handshake like | ||
sender --[Start]--> receiver --[StartIndex]--> sender | ||
and then it can start working |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters