Skip to content

Commit f4c8190

Browse files
Nishant GauravNishant Gaurav
authored andcommitted
fix: resolve merge conflict with upstream main
2 parents e7283d0 + 84b8a46 commit f4c8190

5 files changed

Lines changed: 149 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@ on:
55
branches: [ main, dev ]
66
pull_request:
77
branches: [ main, dev ]
8+
issues:
9+
types: [opened, edited]
10+
issue_comment:
11+
types: [created, edited]
12+
pull_request_target:
13+
types: [opened, edited, synchronize]
14+
pull_request_review_comment:
15+
types: [created, edited]
816

917
permissions:
1018
contents: read
1119
security-events: write
20+
issues: write
21+
pull-requests: write
1222

1323
jobs:
1424
test:
1525
runs-on: ubuntu-latest
26+
if: github.event_name == 'push' || github.event_name == 'pull_request'
1627
strategy:
1728
matrix:
1829
go-version: ['1.24']
@@ -64,6 +75,7 @@ jobs:
6475

6576
lint:
6677
runs-on: ubuntu-latest
78+
if: github.event_name == 'push' || github.event_name == 'pull_request'
6779
steps:
6880
- name: Checkout code
6981
uses: actions/checkout@v4
@@ -85,6 +97,7 @@ jobs:
8597

8698
security:
8799
runs-on: ubuntu-latest
100+
if: github.event_name == 'push' || github.event_name == 'pull_request'
88101
permissions:
89102
security-events: write
90103
actions: read
@@ -124,6 +137,7 @@ jobs:
124137

125138
build:
126139
runs-on: ubuntu-latest
140+
if: github.event_name == 'push' || github.event_name == 'pull_request'
127141
needs: [test, lint]
128142
strategy:
129143
matrix:
@@ -166,6 +180,7 @@ jobs:
166180

167181
integration:
168182
runs-on: ubuntu-latest
183+
if: github.event_name == 'push' || github.event_name == 'pull_request'
169184
needs: [test]
170185
steps:
171186
- name: Checkout code
@@ -214,6 +229,7 @@ jobs:
214229

215230
dependency-check:
216231
runs-on: ubuntu-latest
232+
if: github.event_name == 'push' || github.event_name == 'pull_request'
217233
steps:
218234
- name: Checkout code
219235
uses: actions/checkout@v4
@@ -238,3 +254,51 @@ jobs:
238254
git diff
239255
exit 1
240256
fi
257+
258+
ai-pr-detection:
259+
runs-on: ubuntu-latest
260+
if: github.event_name == 'pull_request_target' || github.event_name == 'pull_request_review_comment'
261+
permissions:
262+
issues: write
263+
pull-requests: write
264+
steps:
265+
- name: AI PR Detection
266+
uses: github/ai-moderator@v1.1.2
267+
with:
268+
token: ${{ secrets.GITHUB_TOKEN }}
269+
spam-label: spam
270+
ai-label: ai-generated
271+
minimize-detected-comments: false
272+
enable-spam-detection: false
273+
enable-link-spam-detection: false
274+
enable-ai-detection: true
275+
276+
ai-issue-moderation:
277+
runs-on: ubuntu-latest
278+
if: github.event_name == 'issues' || github.event_name == 'issue_comment'
279+
permissions:
280+
issues: write
281+
pull-requests: write
282+
steps:
283+
- name: AI Issue and Comment Moderator
284+
uses: github/ai-moderator@v1.1.2
285+
with:
286+
token: ${{ secrets.GITHUB_TOKEN }}
287+
spam-label: spam
288+
ai-label: ai-generated
289+
minimize-detected-comments: true
290+
enable-spam-detection: true
291+
enable-link-spam-detection: true
292+
enable-ai-detection: true
293+
294+
contributors-readme:
295+
runs-on: ubuntu-latest
296+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
297+
permissions:
298+
contents: write
299+
pull-requests: write
300+
steps:
301+
- name: Contribute List
302+
uses: akhilmhdh/contributors-readme-action@v2.3.11
303+
env:
304+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,37 @@ Built with ❤️ in Go by the open source community.
240240
241241
## Contributors
242242
243-
Thanks to all our amazing contributors!
244-
245-
[![Contributors](https://contrib.rocks/image?repo=substantialcattle5/sietch)](https://github.com/substantialcattle5/sietch/graphs/contributors)
243+
Thanks to all our amazing contributors!
244+
245+
<!-- readme: contributors -start -->
246+
<table>
247+
<tbody>
248+
<tr>
249+
<td align="center">
250+
<a href="https://github.com/SubstantialCattle5">
251+
<img src="https://avatars.githubusercontent.com/u/92233871?v=4" width="100;" alt="SubstantialCattle5"/>
252+
<br />
253+
<sub><b>Nilay Nath Sharan</b></sub>
254+
</a>
255+
</td>
256+
<td align="center">
257+
<a href="https://github.com/MrKeiKun">
258+
<img src="https://avatars.githubusercontent.com/u/4362134?v=4" width="100;" alt="MrKeiKun"/>
259+
<br />
260+
<sub><b>Lorenzo (Kei) Buitizon</b></sub>
261+
</a>
262+
</td>
263+
<td align="center">
264+
<a href="https://github.com/ABHINAVGARG05">
265+
<img src="https://avatars.githubusercontent.com/u/143117260?v=4" width="100;" alt="ABHINAVGARG05"/>
266+
<br />
267+
<sub><b>Abhinav Garg</b></sub>
268+
</a>
269+
</td>
270+
</tr>
271+
<tbody>
272+
</table>
273+
<!-- readme: contributors -end -->
246274
247275
## License
248276

cmd/add.go

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import (
2323
"github.com/substantialcattle5/sietch/util"
2424
)
2525

26+
// SpaceSavings represents space savings statistics for a file
27+
type SpaceSavings struct {
28+
OriginalSize int64
29+
CompressedSize int64
30+
SpaceSaved int64
31+
SpaceSavedPct float64
32+
}
33+
2634
// addCmd represents the add command
2735
var addCmd = &cobra.Command{
2836
Use: "add <source_path> <destination_path> [source_path2] [destination_path2]...",
@@ -128,6 +136,7 @@ Examples:
128136
// Process each file pair
129137
successCount := 0
130138
var failedFiles []string
139+
var totalSpaceSavings SpaceSavings
131140

132141
// Show initial progress for multiple files
133142
if len(filePairs) > 1 {
@@ -312,14 +321,21 @@ Examples:
312321

313322
fmt.Printf(" • Compression: %s\n", vaultConfig.Compression)
314323

315-
// Calculate and show space savings if compression is used
316-
if vaultConfig.Compression != "none" {
317-
// TODO: Calculate actual space savings during processing
318-
// For now, show compression info
319-
fmt.Printf(" • Compression: %s (space savings calculated during processing)\n", vaultConfig.Compression)
320-
}
321-
322324
fmt.Printf(" • Chunking: %s (size: %s)\n", vaultConfig.Chunking.Strategy, vaultConfig.Chunking.ChunkSize)
325+
326+
// Show total space savings if compression is used
327+
if vaultConfig.Compression != "none" && totalSpaceSavings.SpaceSaved > 0 {
328+
totalSpaceSavedPct := float64(0)
329+
if totalSpaceSavings.OriginalSize > 0 {
330+
totalSpaceSavedPct = float64(totalSpaceSavings.SpaceSaved) / float64(totalSpaceSavings.OriginalSize) * 100
331+
}
332+
fmt.Printf("\n💾 Total Space Savings:\n")
333+
fmt.Printf(" • Original size: %s\n", util.HumanReadableSize(totalSpaceSavings.OriginalSize))
334+
fmt.Printf(" • Compressed size: %s\n", util.HumanReadableSize(totalSpaceSavings.CompressedSize))
335+
fmt.Printf(" • Space saved: %s (%.1f%%)\n",
336+
util.HumanReadableSize(totalSpaceSavings.SpaceSaved),
337+
totalSpaceSavedPct)
338+
}
323339
}
324340

325341
// Return error only if all files failed
@@ -337,6 +353,35 @@ type FilePair struct {
337353
Destination string
338354
}
339355

356+
// calculateSpaceSavings calculates space savings for a file based on its chunks
357+
func calculateSpaceSavings(chunks []config.ChunkRef) SpaceSavings {
358+
originalSize := int64(0)
359+
compressedSize := int64(0)
360+
361+
for _, chunk := range chunks {
362+
originalSize += chunk.Size
363+
if chunk.CompressedSize > 0 {
364+
compressedSize += chunk.CompressedSize
365+
} else {
366+
// If no compressed size is recorded, use original size
367+
compressedSize += chunk.Size
368+
}
369+
}
370+
371+
spaceSaved := originalSize - compressedSize
372+
var spaceSavedPct float64
373+
if originalSize > 0 {
374+
spaceSavedPct = float64(spaceSaved) / float64(originalSize) * 100
375+
}
376+
377+
return SpaceSavings{
378+
OriginalSize: originalSize,
379+
CompressedSize: compressedSize,
380+
SpaceSaved: spaceSaved,
381+
SpaceSavedPct: spaceSavedPct,
382+
}
383+
}
384+
340385
// parseFileArguments parses command line arguments into source-destination pairs
341386
// Supports two patterns:
342387
// 1. Paired: source1 dest1 source2 dest2 ... (even number of args)

internal/chunk/chunkFile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func processFileChunks(ctx context.Context, file *os.File, chunkSize int64, vaul
138138
chunkRef := config.ChunkRef{
139139
Hash: chunkHash,
140140
Size: int64(bytesRead),
141+
CompressedSize: int64(len(compressedData)),
141142
Index: chunkCount - 1, // Convert 1-based chunkCount to 0-based index
142143
Compressed: vaultConfig.Compression != "none",
143144
CompressionType: vaultConfig.Compression,

internal/config/vault.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ type ChunkRef struct {
166166
Hash string `yaml:"hash"` // Hash of chunk content (pre-encryption)
167167
EncryptedHash string `yaml:"encrypted_hash,omitempty"` // Hash of encrypted chunk (filename in storage)
168168
Size int64 `yaml:"size"` // Size of plaintext chunk
169+
CompressedSize int64 `yaml:"compressed_size,omitempty"` // Size after compression but before encryption
169170
EncryptedSize int64 `yaml:"encrypted_size,omitempty"` // Size after encryption
170171
Index int `yaml:"index"` // Position in the file
171172
Deduplicated bool `yaml:"deduplicated,omitempty"` // Whether this chunk was deduplicated

0 commit comments

Comments
 (0)