@@ -143,36 +143,47 @@ func (fs *TorrentFS) GetFile(infohash string, subpath string) ([]byte, error) {
143143 }
144144 fn := path .Join (fs .config .DataDir , infohash , subpath )
145145 data , err := ioutil .ReadFile (fn )
146- if subpath == "/data" {
147- if int64 (len (data )) != torrent .BytesCompleted () {
148- log .Error ("Read file not completed" , "hash" , infohash , "len" , len (data ), "total" , torrent .BytesCompleted ())
149- return nil , errors .New ("not a complete file" )
150- } else {
151- log .Warn ("Read data sucess" , "hash" , infohash , "size" , len (data ), "path" , subpath )
146+ for _ , file := range torrent .Files () {
147+ if file .Path () == subpath {
148+ if int64 (len (data )) != file .Length () {
149+ log .Error ("Read file not completed" , "hash" , infohash , "len" , len (data ), "total" , file .Path ())
150+ return nil , errors .New ("not a complete file" )
151+ } else {
152+ log .Warn ("Read data sucess" , "hash" , infohash , "size" , len (data ), "path" , file .Path ())
153+ }
152154 }
153- } else if subpath == "/data/symbol" {
154- for _ , file := range torrent .Files () {
155- if file .Path () == "/data/symbol" {
156- if int64 (len (data )) != file .Length () {
157- log .Error ("Read file not completed" , "hash" , infohash , "len" , len (data ), "total" , file .Path ())
158- return nil , errors .New ("not a complete file" )
159- } else {
160- log .Warn ("Read data sucess" , "hash" , infohash , "size" , len (data ), "path" , file .Path ())
155+ }
156+ /*
157+ if subpath == "/data" {
158+ if int64(len(data)) != torrent.BytesCompleted() {
159+ log.Error("Read file not completed", "hash", infohash, "len", len(data), "total", torrent.BytesCompleted())
160+ return nil, errors.New("not a complete file")
161+ } else {
162+ log.Warn("Read data sucess", "hash", infohash, "size", len(data), "path", subpath)
163+ }
164+ } else if subpath == "/data/symbol" {
165+ for _, file := range torrent.Files() {
166+ if file.Path() == "/data/symbol" {
167+ if int64(len(data)) != file.Length() {
168+ log.Error("Read file not completed", "hash", infohash, "len", len(data), "total", file.Path())
169+ return nil, errors.New("not a complete file")
170+ } else {
171+ log.Warn("Read data sucess", "hash", infohash, "size", len(data), "path", file.Path())
172+ }
161173 }
162174 }
163- }
164- } else if subpath == "/data/params" {
165- for _ , file := range torrent . Files () {
166- if file . Path () == "/data/params" {
167- if int64 ( len (data )) != file .Length () {
168- log . Error ( "Read file not completed" , "hash" , infohash , "len" , len ( data ), "total" , file . Path () )
169- return nil , errors . New ( "not a complete file" )
170- } else {
171- log . Warn ( "Read data sucess" , "hash" , infohash , "size" , len ( data ), "path" , file . Path ())
175+ } else if subpath == "/data/params" {
176+ for _, file := range torrent.Files() {
177+ if file.Path() == "/data/params" {
178+ if int64(len(data)) != file.Length() {
179+ log.Error("Read file not completed", "hash", infohash, " len", len (data), "total", file.Path())
180+ return nil, errors.New(" not a complete file" )
181+ } else {
182+ log.Warn("Read data sucess", "hash", infohash, "size", len(data), "path", file.Path())
183+ }
172184 }
173185 }
174- }
175- }
186+ }*/
176187 return data , err
177188 }
178189}
0 commit comments