@@ -117,60 +117,59 @@ func (host *DriverHost) Log(level plugin_warp.LogLevel, message string) {
117117 }
118118}
119119
120- // load-config: func() -> result<string , string>;
120+ // load-config: func(driver: u32 ) -> result<list<u8> , string>;
121121func (host * DriverHost ) LoadConfig (driverHandle uint32 ) witgo.Result [[]byte , string ] {
122122 driver , ok := host .driver .Get (driverHandle )
123123 if ! ok || driver == nil {
124- return witgo.Err [[]byte , string ]("host.driver is null, loading timing too early" )
124+ return witgo.Err [[]byte ]("host.driver is null, loading timing too early" )
125125 }
126126 return witgo.Ok [[]byte , string ](driver .additional .Bytes ())
127127}
128128
129- // save-config: func(config: string ) -> result<_, string>;
129+ // save-config: func(driver: u32, config: list<u8> ) -> result<_, string>;
130130func (host * DriverHost ) SaveConfig (driverHandle uint32 , config []byte ) witgo.Result [witgo.Unit , string ] {
131131 driver , ok := host .driver .Get (driverHandle )
132132 if ! ok || driver == nil {
133- return witgo.Err [witgo.Unit , string ]("host.driver is null, loading timing too early" )
133+ return witgo.Err [witgo.Unit ]("host.driver is null, loading timing too early" )
134134 }
135135
136136 driver .additional .SetBytes (config )
137137 op .MustSaveDriverStorage (driver )
138138 return witgo.Ok [witgo.Unit , string ](witgo.Unit {})
139139}
140140
141- // stream : func() -> result<output -stream, string>;
142- func (host * DriverHost ) Stream (this plugin_warp.UploadReadable ) witgo.Result [io_v0_2.OutputStream , string ] {
141+ // streams : func() -> result<input -stream, string>;
142+ func (host * DriverHost ) Stream (this plugin_warp.UploadReadable ) witgo.Result [io_v0_2.InputStream , string ] {
143143 upload , ok := host .uploads .Get (this )
144144 if ! ok {
145- return witgo.Err [io_v0_2.OutputStream , string ]("UploadReadable::Stream: ErrorCodeBadDescriptor" )
145+ return witgo.Err [io_v0_2.InputStream ]("UploadReadable::Stream: ErrorCodeBadDescriptor" )
146146 }
147-
148- if ! upload .StreamConsume {
149- upload .StreamConsume = true
150- streamHandle := host .StreamManager ().Add (manager_io .NewAsyncStreamForReader (upload ))
151- return witgo.Ok [io_v0_2.OutputStream , string ](streamHandle )
147+ if upload .StreamConsume {
148+ return witgo.Err [io_v0_2.InputStream ]("UploadReadable::Stream: StreamConsume" )
152149 }
153- return witgo.Err [io_v0_2.OutputStream , string ]("UploadReadable::Stream: StreamConsume" )
150+
151+ upload .StreamConsume = true
152+ streamHandle := host .StreamManager ().Add (& manager_io.Stream {Reader : upload , Seeker : upload .GetFile ()})
153+ return witgo.Ok [io_v0_2.InputStream , string ](streamHandle )
154154}
155155
156- // stream- peek: func(offset: u64, len: u64) -> result<output -stream, string>;
157- func (host * DriverHost ) StreamPeek (this plugin_warp.UploadReadable , offset uint64 , len uint64 ) witgo.Result [io_v0_2.OutputStream , string ] {
156+ // peek: func(offset: u64, len: u64) -> result<input -stream, string>;
157+ func (host * DriverHost ) StreamPeek (this plugin_warp.UploadReadable , offset uint64 , len uint64 ) witgo.Result [io_v0_2.InputStream , string ] {
158158 upload , ok := host .uploads .Get (this )
159159 if ! ok {
160- return witgo.Err [io_v0_2.OutputStream ]("UploadReadable::StreamPeek: ErrorCodeBadDescriptor" )
160+ return witgo.Err [io_v0_2.InputStream ]("UploadReadable::StreamPeek: ErrorCodeBadDescriptor" )
161161 }
162-
163162 if upload .StreamConsume {
164- return witgo.Err [io_v0_2.OutputStream ]("UploadReadable::StreamPeek: StreamConsume" )
163+ return witgo.Err [io_v0_2.InputStream ]("UploadReadable::StreamPeek: StreamConsume" )
165164 }
166165
167166 peekReader , err := upload .RangeRead (http_range.Range {Start : int64 (offset ), Length : int64 (len )})
168167 if err != nil {
169- return witgo.Err [io_v0_2.OutputStream ](err .Error ())
168+ return witgo.Err [io_v0_2.InputStream ](err .Error ())
170169 }
171-
172- streamHandle := host .StreamManager ().Add (& manager_io.Stream {Reader : peekReader })
173- return witgo.Ok [io_v0_2.OutputStream , string ](streamHandle )
170+ seeker , _ := peekReader .(io. Seeker )
171+ streamHandle := host .StreamManager ().Add (& manager_io.Stream {Reader : peekReader , Seeker : seeker })
172+ return witgo.Ok [io_v0_2.InputStream , string ](streamHandle )
174173}
175174
176175// chunks: func(len: u32) -> result<u32, string>;
@@ -185,6 +184,7 @@ func (host *DriverHost) Chunks(this plugin_warp.UploadReadable, len uint32) witg
185184 if upload .SectionReader != nil {
186185 return witgo.Err [uint32 ]("UploadReadable::Chunks: Already exist chunk reader" )
187186 }
187+
188188 ss , err := stream .NewStreamSectionReader (upload , int (len ), & upload .UpdateProgress )
189189 if err != nil {
190190 return witgo.Err [uint32 ](err .Error ())
@@ -233,7 +233,7 @@ func (host *DriverHost) ChunkReset(this plugin_warp.UploadReadable, chunk io_v0_
233233 return witgo.Ok [witgo.Unit , string ](witgo.Unit {})
234234}
235235
236- // get-hasher: func(hashs: list<hash-alg>) -> result<hash-info, string>;
236+ // get-hasher: func(hashs: list<hash-alg>) -> result<list< hash-info> , string>;
237237func (host * DriverHost ) GetHasher (this plugin_warp.UploadReadable , hashs []plugin_warp.HashAlg ) witgo.Result [[]plugin_warp.HashInfo , string ] {
238238 upload , ok := host .uploads .Get (this )
239239 if ! ok {
0 commit comments