Fix file names
This commit is contained in:
parent
54ec7cac27
commit
2370d666c0
|
|
@ -246,7 +246,10 @@ func (h *CorpusHandler) Upload(c *gin.Context) {
|
||||||
runID = &uid
|
runID = &uid
|
||||||
}
|
}
|
||||||
|
|
||||||
blobKey := fmt.Sprintf("corpus/%s/%s/%s", target.RepoName, target.Name, header.Filename)
|
// Use a unique prefix to avoid filename collisions across runs.
|
||||||
|
var entryCount int64
|
||||||
|
h.DB.WithContext(ctx).Model(&models.CorpusEntry{}).Where("target_id = ?", targetID).Count(&entryCount)
|
||||||
|
blobKey := fmt.Sprintf("corpus/%s/%s/%d-%s", target.RepoName, target.Name, entryCount, header.Filename)
|
||||||
|
|
||||||
if err := h.Store.Put(ctx, blobKey, file, header.Size); err != nil {
|
if err := h.Store.Put(ctx, blobKey, file, header.Size); err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "storing blob: " + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "storing blob: " + err.Error()})
|
||||||
|
|
@ -362,7 +365,7 @@ func (h *CorpusHandler) DownloadAll(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
Name: filepath.Base(entry.BlobKey),
|
Name: fmt.Sprintf("%d-%s", entry.ID, filepath.Base(entry.BlobKey)),
|
||||||
Mode: 0o644,
|
Mode: 0o644,
|
||||||
Size: int64(len(data)),
|
Size: int64(len(data)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue