Commit f969ffd
Eric Bower
·
2026-03-05 20:33:25 -0500 EST
parent 45aaf05
chore(pgs): setting acl is pico+ only
2 files changed,
+19,
-0
+15,
-0
| ... | ... | @@ -5,6 +5,7 @@ import ( | |
| 5 | 5 | "fmt" | |
| 6 | 6 | "slices" | |
| 7 | 7 | "strings" | |
| 8 | + | "time" | |
| 8 | 9 | ||
| 9 | 10 | pgsdb "github.com/picosh/pico/pkg/apps/pgs/db" | |
| 10 | 11 | "github.com/picosh/pico/pkg/db" |
| ... | ... | @@ -236,6 +237,20 @@ func Middleware(handler *UploadAssetHandler) pssh.SSHServerMiddleware { | |
| 236 | 237 | return err | |
| 237 | 238 | } | |
| 238 | 239 | ||
| 240 | + | hasPicoPlus := false | |
| 241 | + | ff, _ := dbpool.FindFeature(user.ID, "plus") | |
| 242 | + | if ff != nil { | |
| 243 | + | if ff.ExpiresAt.After(time.Now()) { | |
| 244 | + | hasPicoPlus = true | |
| 245 | + | } | |
| 246 | + | } | |
| 247 | + | ||
| 248 | + | if !hasPicoPlus { | |
| 249 | + | err = fmt.Errorf("setting acl on a project requires pico+") | |
| 250 | + | opts.bail(err) | |
| 251 | + | return err | |
| 252 | + | } | |
| 253 | + | ||
| 239 | 254 | if pgsdb.IsProjectPrivate(projectName) { | |
| 240 | 255 | err = fmt.Errorf("projects prefixed with `private-` can *never* have their access changed; however you can symlink to it") | |
| 241 | 256 | opts.bail(err) |
+4,
-0
| ... | ... | @@ -336,6 +336,10 @@ func (h *UploadAssetHandler) Write(s *pssh.SSHServerConnSession, entry *sendutil | |
| 336 | 336 | } | |
| 337 | 337 | ||
| 338 | 338 | featureFlag := findPlusFF(h.Cfg.DB, h.Cfg, user.ID) | |
| 339 | + | if !featureFlag.IsValid() && pgsdb.IsProjectPrivate(projectName) { | |
| 340 | + | return "", fmt.Errorf("private projects are only allowed for pico+ users") | |
| 341 | + | } | |
| 342 | + | ||
| 339 | 343 | // calculate the filsize difference between the same file already | |
| 340 | 344 | // stored and the updated file being uploaded | |
| 341 | 345 | assetFilename := shared.GetAssetFileName(entry) |