Skip to content

Commit

Permalink
refactor: Removing captain obvious comment
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Mar 12, 2023
1 parent a6e4ad1 commit 281d013
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 45 deletions.
1 change: 0 additions & 1 deletion pkg/crud/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (a App) Delete(w http.ResponseWriter, r *http.Request, request provider.Req
a.rendererApp.Redirect(w, r, fmt.Sprintf("?d=%s", request.Display), renderer.NewSuccessMessage("%s successfully deleted", info.Name))
}

// Delete given path from filesystem
func (a App) DeleteSavedSearch(w http.ResponseWriter, r *http.Request, request provider.Request) {
if !request.CanEdit {
a.error(w, r, request, model.WrapForbidden(ErrNotAuthorized))
Expand Down
1 change: 0 additions & 1 deletion pkg/crud/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (a App) enrichThumbnail(ctx context.Context, directoryAggregate provider.Ag
return
}

// Download content of a directory into a streamed zip
func (a App) Download(w http.ResponseWriter, r *http.Request, request provider.Request, items []absto.Item) {
zipWriter := zip.NewWriter(w)
defer func() {
Expand Down
2 changes: 0 additions & 2 deletions pkg/fibr/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/renderer"
)

// FuncMap is the map of function available in templates
var FuncMap = template.FuncMap{
"rebuildPaths": func(parts []string, index int) string {
return fmt.Sprintf("/%s/", strings.Join(parts[:index+1], "/"))
Expand Down Expand Up @@ -63,7 +62,6 @@ var FuncMap = template.FuncMap{
},
}

// TemplateFunc for rendering GUI
func (a App) TemplateFunc(w http.ResponseWriter, r *http.Request) (renderer.Page, error) {
if !isMethodAllowed(r) {
return renderer.Page{}, model.WrapMethodNotAllowed(errors.New("you lack of method for calling me"))
Expand Down
1 change: 0 additions & 1 deletion pkg/geo/geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func NewPosition(lon, lat float64) Position {
}
}

// MarshalJSON marshals the position as an array.
func (p Position) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("[%f,%f]", p.Longitude, p.Latitude)), nil
}
14 changes: 0 additions & 14 deletions pkg/provider/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,21 @@ import (
"go.opentelemetry.io/otel/trace"
)

// EventType is the enumeration of event that can happen
type EventType uint

// EventProducer is a func that push an event
type EventProducer func(Event) error

// EventConsumer is a func that consume an event
type EventConsumer func(context.Context, Event)

// Renamer is a func that rename an item
type Renamer func(context.Context, absto.Item, absto.Item) error

const (
// UploadEvent occurs when someone upload a file
UploadEvent EventType = iota
// CreateDir occurs when a directory is created
CreateDir
// RenameEvent occurs when an item is renamed
RenameEvent
// DeleteEvent occurs when an item is deleted
DeleteEvent
// StartEvent occurs when fibr start
StartEvent
// AccessEvent occurs when content is accessed
AccessEvent
// DescriptionEvent occurs when a description is added
DescriptionEvent
)

Expand All @@ -65,7 +54,6 @@ func (et EventType) String() string {
return eventTypeValues[et]
}

// MarshalJSON marshals the enum as a quoted json string
func (et EventType) MarshalJSON() ([]byte, error) {
buffer := bytes.NewBufferString(`"`)
buffer.WriteString(et.String())
Expand Down Expand Up @@ -100,7 +88,6 @@ type Event struct {
Type EventType `json:"type"`
}

// IsForcedFor check if event is forced for given key
func (e Event) IsForcedFor(key string) bool {
force := e.GetMetadata("force")

Expand Down Expand Up @@ -267,7 +254,6 @@ func NewAccessEvent(item absto.Item, r *http.Request) Event {
}
}

// EventBus describes a channel for exchanging Event
type EventBus struct {
tracer trace.Tracer
counter *prometheus.CounterVec
Expand Down
5 changes: 1 addition & 4 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import (
)

const (
// MetadataDirectoryName directory where metadata are stored
MetadataDirectoryName = "/.fibr"

// MaxConcurrency defines how many concurrent task can be launch in parallel when possible
MaxConcurrency = uint64(6)
MaxConcurrency = uint64(6)
)

var (
Expand Down
9 changes: 2 additions & 7 deletions pkg/provider/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ import (
type Display string

var (
// GridDisplay format
GridDisplay Display = "grid"
// ListDisplay format
ListDisplay Display = "list"
// StoryDisplay format
GridDisplay Display = "grid"
ListDisplay Display = "list"
StoryDisplay Display = "story"

// DefaultDisplay format
DefaultDisplay = GridDisplay

// LayoutPathsCookieName for saving preferences
LayoutPathsCookieName = "layout_paths"

preferencesPathSeparator = "|"
Expand Down
1 change: 0 additions & 1 deletion pkg/provider/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func greaterTime(first, second time.Time) bool {
return first.After(second)
}

// ByHybridSort implements Sorter by type then modification time
type ByHybridSort []absto.Item

func (a ByHybridSort) Len() int {
Expand Down
1 change: 0 additions & 1 deletion pkg/share/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/logger"
)

// EventConsumer handle event pushed to the event bus
func (a *App) EventConsumer(ctx context.Context, e provider.Event) {
switch e.Type {
case provider.RenameEvent:
Expand Down
2 changes: 0 additions & 2 deletions pkg/thumbnail/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
absto "github.com/ViBiOh/absto/pkg/model"
)

// ListDirLarge return all thumbnails for large size for a given directory
func (a App) ListDirLarge(ctx context.Context, item absto.Item) (map[string]absto.Item, error) {
return a.listDirectoryForScale(ctx, item, a.largeStorageApp)
}

// ListDir return all thumbnails for a given directory
func (a App) ListDir(ctx context.Context, item absto.Item) (map[string]absto.Item, error) {
return a.listDirectoryForScale(ctx, item, a.smallStorageApp)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/thumbnail/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/ViBiOh/httputils/v4/pkg/logger"
)

// EventConsumer handle event pushed to the event bus
func (a App) EventConsumer(ctx context.Context, e provider.Event) {
if a.vithRequest.IsZero() && a.amqpClient == nil {
return
Expand All @@ -31,7 +30,6 @@ func (a App) EventConsumer(ctx context.Context, e provider.Event) {
}
}

// Rename thumbnail of an item
func (a App) Rename(ctx context.Context, old, new absto.Item) error {
if old.IsDir {
return nil
Expand Down
1 change: 0 additions & 1 deletion pkg/thumbnail/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/ViBiOh/vith/pkg/model"
)

// HasStream checks if given item has a streamable version
func (a App) HasStream(ctx context.Context, item absto.Item) bool {
_, err := a.Info(ctx, getStreamPath(item))
return err == nil
Expand Down
9 changes: 1 addition & 8 deletions pkg/thumbnail/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ import (
"go.opentelemetry.io/otel/trace"
)

const (
// SmallSize is the square size of each thumbnail generated
SmallSize uint64 = 150
)
const SmallSize uint64 = 150

var cacheDuration = fmt.Sprintf("private, max-age=%.0f", (time.Minute * 5).Seconds())

Expand Down Expand Up @@ -146,12 +143,10 @@ func New(config Config, storage absto.Storage, redisClient redis.Client, prometh
return app, nil
}

// LargeThumbnailSize give large thumbnail size
func (a App) LargeThumbnailSize() uint64 {
return a.largeSize
}

// Stream check if stream is present and serve it
func (a App) Stream(w http.ResponseWriter, r *http.Request, item absto.Item) {
reader, err := a.storageApp.ReadFrom(r.Context(), getStreamPath(item))
if err != nil {
Expand All @@ -170,7 +165,6 @@ func (a App) Stream(w http.ResponseWriter, r *http.Request, item absto.Item) {
http.ServeContent(w, r, item.Name, item.Date, reader)
}

// Serve check if thumbnail is present and serve it
func (a App) Serve(w http.ResponseWriter, r *http.Request, item absto.Item) {
if !a.CanHaveThumbnail(item) {
w.WriteHeader(http.StatusNoContent)
Expand Down Expand Up @@ -209,7 +203,6 @@ func (a App) Serve(w http.ResponseWriter, r *http.Request, item absto.Item) {
http.ServeContent(w, r, baseName, item.Date, reader)
}

// List return all thumbnails in a base64 form
func (a App) List(w http.ResponseWriter, r *http.Request, item absto.Item, items []absto.Item) {
if len(items) == 0 {
w.WriteHeader(http.StatusNoContent)
Expand Down

0 comments on commit 281d013

Please sign in to comment.