Skip to content

Commit a9a9f63

Browse files
authored
Merge pull request #72 from Automattic/git-mirror-minimal-size
Only publish git mirror if the archive file is 50 MB or larger
2 parents fdadf06 + 3faf18a commit a9a9f63

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ A description of this package.
44

55
## Release
66

7-
1. Create a PR to update the [`appVersion`](Sources/hostmgr/main.swift).
8-
1. After the PR is merged, create a tag named same as the `appVersion`,
9-
1. Once the tag is pushed up to this repo, a CI job will be automatically kicked off to create a GitHub release for the tag. Wait for the CI job to finish.
10-
1. Update [the hostmgr homebrew formula](https://github.com/Automattic/homebrew-build-tools/blob/trunk/hostmgr.rb)'s `url` and `sha256` fields, whose value can be found in the GitHub release created above.
7+
1. Create a PR to update [the version property](Sources/libhostmgr/libhostmgr.swift).
8+
1. After the PR is merged, create a tag named same as the updated version,
9+
1. Once the tag is pushed up to this repo, a CI job will be automatically kicked off to create a GitHub release for the tag.

Sources/hostmgr/commands/cache/GitMirrorPublishCommand.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ struct GitMirrorPublishCommand: AsyncParsableCommand {
3737
Console.info("Compressing \(gitMirror.localPath.path()) to \(gitMirror.archivePath)")
3838
try gitMirror.compress()
3939

40+
// At the moment `service.uploadFile` does a multi-part upload, which fails if one of those batches is less
41+
// than 5 MB. Instead of implementing a direct upload in tinys3, we'll put a random minimal size limit (50 MB)
42+
// to git mirror files. If the file size is too small, git checkout should be pretty fast and it's okay to not
43+
// save the git repo in S3.
44+
let archiveSize = try FileManager.default.size(ofObjectAt: gitMirror.archivePath)
45+
let archiveSizeInMB = Measurement(value: Double(archiveSize), unit: UnitInformationStorage.bytes)
46+
.converted(to: .megabytes)
47+
if archiveSizeInMB.value < 50 {
48+
Console.info("Skipping uploading the git mirror because it is too small")
49+
return
50+
}
51+
4052
let progress = Console.startProgress("Uploading mirror to \(gitMirror.remoteFilename)", type: .upload)
4153
try await server.uploadFile(at: gitMirror.archivePath, to: gitMirror.remoteFilename, progress: progress.update)
4254

Sources/libhostmgr/libhostmgr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import OSLog
33

4-
public let hostmgrVersion = "0.50.0-beta.10"
4+
public let hostmgrVersion = "0.50.0-beta.11"
55

66
public extension Logger {
77
private static let subsystem = "com.automattic.hostmgr"

0 commit comments

Comments
 (0)