Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 4fe76a1

Browse files
Revert "Merge pull request #18 from sosthene-nitrokey/chunk-api"
This reverts commit cda69dc, reversing changes made to c2cae35.
1 parent bf82433 commit 4fe76a1

10 files changed

Lines changed: 3 additions & 662 deletions

File tree

src/api.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,12 @@ generate_enums! {
4343
ReadDirFilesFirst: 13
4444
ReadDirFilesNext: 14
4545
ReadFile: 15
46-
ReadChunk: 65
4746
Metadata: 26
4847
// ReadCounter: 7
4948
RandomBytes: 16
5049
SerializeKey: 17
5150
Sign: 18
5251
WriteFile: 19
53-
StartChunkedWrite: 66
54-
WriteChunk: 67
55-
FlushChunks: 68
56-
AbortChunkedWrite: 69
5752
UnsafeInjectKey: 20
5853
UnsafeInjectSharedKey: 21
5954
UnwrapKey: 22
@@ -247,10 +242,6 @@ pub mod request {
247242
ReadFile:
248243
- location: Location
249244
- path: PathBuf
250-
ReadChunk:
251-
- location: Location
252-
- pos: OpenSeekFrom
253-
- path: PathBuf
254245

255246
Metadata:
256247
- location: Location
@@ -292,24 +283,6 @@ pub mod request {
292283
- data: Message
293284
- user_attribute: Option<UserAttribute>
294285

295-
StartChunkedWrite:
296-
- location: Location
297-
- path: PathBuf
298-
- data: Message
299-
- user_attribute: Option<UserAttribute>
300-
301-
WriteChunk:
302-
- location: Location
303-
- pos: OpenSeekFrom
304-
- path: PathBuf
305-
- data: Message
306-
FlushChunks:
307-
- location: Location
308-
- path: PathBuf
309-
AbortChunkedWrite:
310-
- location: Location
311-
- path: PathBuf
312-
313286
UnsafeInjectKey:
314287
- mechanism: Mechanism // -> implies key type
315288
- raw_key: SerializedKey
@@ -461,9 +434,6 @@ pub mod reply {
461434

462435
ReadFile:
463436
- data: Message
464-
ReadChunk:
465-
- data: Message
466-
- len: usize
467437

468438
Metadata:
469439
- metadata: Option<crate::types::Metadata>
@@ -488,11 +458,6 @@ pub mod reply {
488458
- signature: Signature
489459

490460
WriteFile:
491-
StartChunkedWrite:
492-
WriteChunk:
493-
FlushChunks:
494-
AbortChunkedWrite:
495-
- aborted: bool
496461

497462
Verify:
498463
- valid: bool

src/client.rs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -622,20 +622,6 @@ pub trait FilesystemClient: PollClient {
622622
self.request(request::ReadFile { location, path })
623623
}
624624

625-
// Read part of a file, up to 1KiB starting at `pos`
626-
fn read_file_chunk(
627-
&mut self,
628-
location: Location,
629-
path: PathBuf,
630-
pos: OpenSeekFrom,
631-
) -> ClientResult<'_, reply::ReadChunk, Self> {
632-
self.request(request::ReadChunk {
633-
location,
634-
path,
635-
pos,
636-
})
637-
}
638-
639625
/// Fetch the Metadata for a file or directory
640626
///
641627
/// If the file doesn't exists, return None
@@ -674,64 +660,6 @@ pub trait FilesystemClient: PollClient {
674660
user_attribute,
675661
})
676662
}
677-
678-
/// Begin writing a file that can be larger than 1KiB
679-
///
680-
/// More chunks can be written with [`write_file_chunk`](FilesystemClient::write_file_chunk).
681-
/// Before the data becomes readable, it needs to be flushed with [`flush_chunks`](FilesystemClient::flush_chunks), or aborted with [`abort_chunked_write`](FilesystemClient::abort_chunked_write)
682-
///
683-
/// Chunked writes are buffered in memory. Failing to abort or flush a chunked write will lead to a memory leak, that can be solved by a power cycle.
684-
fn start_chunked_write(
685-
&mut self,
686-
location: Location,
687-
path: PathBuf,
688-
data: Message,
689-
user_attribute: Option<UserAttribute>,
690-
) -> ClientResult<'_, reply::StartChunkedWrite, Self> {
691-
self.request(request::StartChunkedWrite {
692-
location,
693-
path,
694-
data,
695-
user_attribute,
696-
})
697-
}
698-
699-
/// Write part of a file
700-
///
701-
/// See [`start_chunked_write`](FilesystemClient::start_chunked_write).
702-
fn write_file_chunk(
703-
&mut self,
704-
location: Location,
705-
path: PathBuf,
706-
data: Message,
707-
pos: OpenSeekFrom,
708-
) -> ClientResult<'_, reply::WriteChunk, Self> {
709-
self.request(request::WriteChunk {
710-
location,
711-
path,
712-
data,
713-
pos,
714-
})
715-
}
716-
717-
/// Flush a file opened with [`start_chunked_write`](FilesystemClient::start_chunked_write).
718-
/// Only after this will the content of the file be readable
719-
fn flush_chunks(
720-
&mut self,
721-
location: Location,
722-
path: PathBuf,
723-
) -> ClientResult<'_, reply::FlushChunks, Self> {
724-
self.request(request::FlushChunks { location, path })
725-
}
726-
727-
/// Abort writes to a file opened with [`start_chunked_write`](FilesystemClient::start_chunked_write).
728-
fn abort_chunked_write(
729-
&mut self,
730-
location: Location,
731-
path: PathBuf,
732-
) -> ClientResult<'_, reply::AbortChunkedWrite, Self> {
733-
self.request(request::AbortChunkedWrite { location, path })
734-
}
735663
}
736664

737665
/// All the other methods that are fit to expose.

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub mod serde_extensions;
3636
pub mod service;
3737
pub mod store;
3838
pub mod types;
39-
pub mod utils;
4039

4140
#[cfg(feature = "virt")]
4241
#[cfg_attr(docsrs, doc(cfg(feature = "virt")))]

src/service.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,6 @@ impl<P: Platform> ServiceResources<P> {
433433
}))
434434
}
435435

436-
Request::ReadChunk(request) => {
437-
let (data,len) = filestore.read_chunk(&request.path,request.location,request.pos)?;
438-
Ok(Reply::ReadChunk(reply::ReadChunk {
439-
data,
440-
len,
441-
}))
442-
}
443-
444436
Request::Metadata(request) => {
445437
Ok(Reply::Metadata(reply::Metadata{
446438
metadata: filestore.metadata(&request.path, request.location)?
@@ -490,22 +482,6 @@ impl<P: Platform> ServiceResources<P> {
490482
filestore.write(&request.path, request.location, &request.data)?;
491483
Ok(Reply::WriteFile(reply::WriteFile {} ))
492484
}
493-
Request::StartChunkedWrite(request) => {
494-
filestore.start_chunked_write(&request.path, request.location, &request.data)?;
495-
Ok(Reply::StartChunkedWrite(reply::StartChunkedWrite {} ))
496-
}
497-
Request::WriteChunk(request) => {
498-
filestore.write_chunk(&request.path, request.location, &request.data,request.pos)?;
499-
Ok(Reply::WriteChunk(reply::WriteChunk {} ))
500-
}
501-
Request::FlushChunks(request) => {
502-
filestore.flush_chunks(&request.path, request.location)?;
503-
Ok(Reply::FlushChunks(reply::FlushChunks {} ))
504-
}
505-
Request::AbortChunkedWrite(request) => {
506-
let aborted = filestore.abort_chunked_write(&request.path, request.location);
507-
Ok(Reply::AbortChunkedWrite(reply::AbortChunkedWrite {aborted} ))
508-
}
509485

510486
Request::UnwrapKey(request) => {
511487
match request.mechanism {

0 commit comments

Comments
 (0)