Skip to content

Commit

Permalink
Improved date format and naming of meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriana Baldacchino committed Aug 3, 2023
1 parent d01e09f commit 207ea7c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/app/provider/overleaf/overleaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"net/http"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -55,7 +56,6 @@ func (p *overleafProvider) GetAppURL(ctx context.Context, resource *provider.Res
}

if _, ok := opaqueMap["override"]; !ok {
log.Debug().Msg("not ok")
// Check if resource has already been exported to Overleaf

statRes, err := client.Stat(ctx, &provider.StatRequest{
Expand All @@ -67,13 +67,11 @@ func (p *overleafProvider) GetAppURL(ctx context.Context, resource *provider.Res
return nil, err
}

creationTime, alreadySet := statRes.Info.GetArbitraryMetadata().Metadata["overleaf-exported"]
creationTime, alreadySet := statRes.Info.GetArbitraryMetadata().Metadata["reva.overleaf.time"]

if alreadySet {
return nil, errtypes.AlreadyExists("Project was already exported on " + creationTime + ".")
return nil, errtypes.AlreadyExists("Project was already exported on:" + creationTime)
}
} else {
log.Debug().Msg("ok")
}

// TODO: generate and use a more restricted token
Expand Down Expand Up @@ -117,7 +115,7 @@ func (p *overleafProvider) GetAppURL(ctx context.Context, resource *provider.Res
},
ArbitraryMetadata: &provider.ArbitraryMetadata{
Metadata: map[string]string{
"overleaf-exported": time.Now().Format("2006-01-02"),
"reva.overleaf.time": strconv.Itoa(int(time.Now().Unix())),
},
},
}
Expand Down

0 comments on commit 207ea7c

Please sign in to comment.