File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -462,7 +462,24 @@ Examples:
462
462
return
463
463
case * mfs.File :
464
464
_ , name := gopath .Split (path )
465
- out := & filesLsOutput {[]mfs.NodeListing {mfs.NodeListing {Name : name , Type : 1 }}}
465
+ out := & filesLsOutput {[]mfs.NodeListing {mfs.NodeListing {Name : name }}}
466
+ if long {
467
+ out .Entries [0 ].Type = int (fsn .Type ())
468
+
469
+ size , err := fsn .Size ()
470
+ if err != nil {
471
+ res .SetError (err , cmdkit .ErrNormal )
472
+ return
473
+ }
474
+ out .Entries [0 ].Size = size
475
+
476
+ nd , err := fsn .GetNode ()
477
+ if err != nil {
478
+ res .SetError (err , cmdkit .ErrNormal )
479
+ return
480
+ }
481
+ out .Entries [0 ].Hash = nd .Cid ().String ()
482
+ }
466
483
res .SetOutput (out )
467
484
return
468
485
default :
Original file line number Diff line number Diff line change @@ -186,6 +186,18 @@ test_files_api() {
186
186
test_cmp ls_l_expected ls_l_actual
187
187
'
188
188
189
+ test_expect_success " file has correct hash and size listed with -l" '
190
+ echo "file1 $FILE1 4" > ls_l_expected &&
191
+ ipfs files ls -l /cats/file1 > ls_l_actual &&
192
+ test_cmp ls_l_expected ls_l_actual
193
+ '
194
+
195
+ test_expect_success " file shows up with the correct name" '
196
+ echo "file1" > ls_l_expected &&
197
+ ipfs files ls /cats/file1 > ls_l_actual &&
198
+ test_cmp ls_l_expected ls_l_actual
199
+ '
200
+
189
201
test_expect_success " can stat file $EXTRA " '
190
202
ipfs files stat /cats/file1 > file1stat_orig
191
203
'
You can’t perform that action at this time.
0 commit comments