diff --git a/.github/scripts/command/info.sh b/.github/scripts/command/info.sh new file mode 100755 index 000000000000..917df5d28cf2 --- /dev/null +++ b/.github/scripts/command/info.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +python3 -c "import xattr" || sudo pip install xattr +sudo dpkg -s redis-tools || sudo .github/scripts/apt_install.sh redis-tools +source .github/scripts/common/common.sh + +[[ -z "$META" ]] && META=sqlite3 +source .github/scripts/start_meta_engine.sh +start_meta_engine $META +META_URL=$(get_meta_url $META) + +test_info_big_file(){ + prepare_test + ./juicefs format $META_URL myjfs + ./juicefs mount -d $META_URL /jfs + dd if=/dev/urandom of=/jfs/bigfile bs=16M count=1024 + ./juicefs info /jfs/bigfile +} + +prepare_test() +{ + umount_jfs /jfs $META_URL + ls -l /jfs/.config && exit 1 || true + python3 .github/scripts/flush_meta.py $META_URL + rm -rf /var/jfs/myjfs || true +} + +source .github/scripts/common/run_test.sh && run_test $@ diff --git a/.github/workflows/command.yml b/.github/workflows/command.yml index d9bb11c3d95e..72973cb22e57 100644 --- a/.github/workflows/command.yml +++ b/.github/workflows/command.yml @@ -64,6 +64,10 @@ jobs: - name: Build uses: ./.github/actions/build + - name: Test Info + run: | + sudo META=${{matrix.meta}} .github/scripts/command/info.sh + - name: Test Quota timeout-minutes: 30 run: | diff --git a/cmd/info.go b/cmd/info.go index 175e10b4c2d2..15e7713fecb3 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -89,8 +89,8 @@ func info(ctx *cli.Context) error { if ctx.Bool("raw") { raw = 1 } - progress := utils.NewProgress(recursive == 0) // only show progress for recursive info for i := 0; i < ctx.Args().Len(); i++ { + progress := utils.NewProgress(recursive == 0) // only show progress for recursive info path := ctx.Args().Get(i) dspin := progress.AddDoubleSpinner(path) var d string @@ -228,7 +228,6 @@ func info(ctx *cli.Context) error { printResult(results, 0, false) } } - progress.Done() return nil } diff --git a/cmd/warmup.go b/cmd/warmup.go index 67c7f3fe22e6..7927c55f73c1 100644 --- a/cmd/warmup.go +++ b/cmd/warmup.go @@ -103,11 +103,17 @@ END: off += 17 } else if off+5 < n && resp[off] == meta.CDATA { size := binary.BigEndian.Uint32(resp[off+1 : off+5]) - if off+5+int(size) > n { - logger.Errorf("Bad response off %d n %d: %v", off, n, resp) - break + data = resp[off+5:] + if size > uint32(len(resp[off+5:])) { + tailData, err := io.ReadAll(cf) + if err != nil { + logger.Errorf("Read data error: %v", err) + break END + } + data = append(data, tailData...) + } else { + data = data[:size] } - data = append(data, resp[off+5:off+5+int(size)]...) break END } else { logger.Errorf("Bad response off %d n %d: %v", off, n, resp)