Skip to content

Commit 04c754f

Browse files
Merge pull request #163 from dmcgowan/fix-sparse-file-usage
Fix usage calculation to account for sparse files
2 parents f2cc351 + bc5e3ed commit 04c754f

2 files changed

Lines changed: 21 additions & 60 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,23 @@ on:
88

99
jobs:
1010

11-
checks:
12-
name: CI Checks
11+
#
12+
# Project checks
13+
#
14+
project:
15+
name: Project Checks
1316
runs-on: ubuntu-18.04
1417
timeout-minutes: 5
15-
steps:
16-
17-
- name: Set up Go
18-
uses: actions/setup-go@v1
19-
with:
20-
go-version: 1.15
21-
id: go
22-
23-
- name: Setup Go binary path
24-
shell: bash
25-
run: |
26-
echo "::set-env name=GOPATH::${{ github.workspace }}"
27-
echo "::add-path::${{ github.workspace }}/bin"
28-
29-
- name: Check out code
30-
uses: actions/checkout@v2
31-
with:
32-
path: src/github.com/containerd/continuity
33-
fetch-depth: 25
34-
35-
- name: Checkout project
36-
uses: actions/checkout@v2
37-
with:
38-
repository: containerd/project
39-
path: src/github.com/containerd/project
40-
41-
- name: Install dependencies
42-
env:
43-
GO111MODULE: off
44-
run: |
45-
go get -u github.com/vbatts/git-validation
46-
go get -u github.com/kunalkushwaha/ltag
4718

48-
- name: Check DCO/whitespace/commit message
49-
env:
50-
GITHUB_COMMIT_URL: ${{ github.event.pull_request.commits_url }}
51-
DCO_VERBOSITY: "-q"
52-
DCO_RANGE: ""
53-
working-directory: src/github.com/containerd/continuity
54-
run: |
55-
if [ -z "${GITHUB_COMMIT_URL}" ]; then
56-
DCO_RANGE=$(jq -r '.before +".."+ .after' ${GITHUB_EVENT_PATH})
57-
else
58-
DCO_RANGE=$(curl ${GITHUB_COMMIT_URL} | jq -r '.[0].parents[0].sha +".."+ .[-1].sha')
59-
fi
60-
../project/script/validate/dco
61-
62-
- name: Check file headers
63-
run: ../project/script/validate/fileheader ../project/
64-
working-directory: src/github.com/containerd/continuity
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
path: src/github.com/containerd/continuity
23+
fetch-depth: 100
6524

66-
- name: Check vendor
67-
run: ../project/script/validate/vendor
68-
working-directory: src/github.com/containerd/continuity
25+
- uses: containerd/project-checks@v1
26+
with:
27+
working-directory: src/github.com/containerd/continuity
6928

7029
tests:
7130
name: CI Tests
@@ -86,8 +45,8 @@ jobs:
8645
- name: Setup Go binary path
8746
shell: bash
8847
run: |
89-
echo "::set-env name=GOPATH::${{ github.workspace }}"
90-
echo "::add-path::${{ github.workspace }}/bin"
48+
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
49+
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
9150
9251
- name: Git line endings
9352
shell: bash

fs/du_unix.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ func diskUsage(ctx context.Context, roots ...string) (Usage, error) {
5959
default:
6060
}
6161

62-
inoKey := newInode(fi.Sys().(*syscall.Stat_t))
62+
stat := fi.Sys().(*syscall.Stat_t)
63+
inoKey := newInode(stat)
6364
if _, ok := inodes[inoKey]; !ok {
6465
inodes[inoKey] = struct{}{}
65-
size += fi.Size()
66+
size += stat.Blocks * stat.Blksize
6667
}
6768

6869
return nil
@@ -89,10 +90,11 @@ func diffUsage(ctx context.Context, a, b string) (Usage, error) {
8990
}
9091

9192
if kind == ChangeKindAdd || kind == ChangeKindModify {
92-
inoKey := newInode(fi.Sys().(*syscall.Stat_t))
93+
stat := fi.Sys().(*syscall.Stat_t)
94+
inoKey := newInode(stat)
9395
if _, ok := inodes[inoKey]; !ok {
9496
inodes[inoKey] = struct{}{}
95-
size += fi.Size()
97+
size += stat.Blocks * stat.Blksize
9698
}
9799

98100
return nil

0 commit comments

Comments
 (0)