@@ -2,6 +2,7 @@ package pkgs
2
2
3
3
import (
4
4
"context"
5
+ b64 "encoding/base64"
5
6
"encoding/json"
6
7
"io/ioutil"
7
8
"net/url"
@@ -31,7 +32,7 @@ func (c *Indexes) Add(ctx context.Context, payload *indexes.IndexPayload) (*inde
31
32
}
32
33
33
34
// Download tmp file
34
- filename := url .PathEscape (payload .URL )
35
+ filename := b64 . StdEncoding . EncodeToString ([] byte ( url .PathEscape (payload .URL )) )
35
36
path := filepath .Join (c .Folder , filename + ".tmp" )
36
37
d , err := downloader .Download (path , indexURL .String ())
37
38
if err != nil {
@@ -53,7 +54,7 @@ func (c *Indexes) Add(ctx context.Context, payload *indexes.IndexPayload) (*inde
53
54
54
55
// Get reads the index file from the Indexes Folder, unmarshaling it
55
56
func (c * Indexes ) Get (ctx context.Context , uri string ) (index Index , err error ) {
56
- filename := url .PathEscape (uri )
57
+ filename := b64 . StdEncoding . EncodeToString ([] byte ( url .PathEscape (uri )) )
57
58
path := filepath .Join (c .Folder , filename )
58
59
data , err := ioutil .ReadFile (path )
59
60
if err != nil {
@@ -74,17 +75,20 @@ func (c *Indexes) List(context.Context) ([]string, error) {
74
75
_ = os .MkdirAll (c .Folder , 0755 )
75
76
// Read files
76
77
files , err := ioutil .ReadDir (c .Folder )
78
+
77
79
if err != nil {
78
80
return nil , err
79
81
}
80
82
81
83
res := []string {}
82
84
for _ , file := range files {
83
85
// Select only files that begin with http
84
- if ! strings .HasPrefix (file .Name (), "http" ) {
86
+ decodedFileName , _ := b64 .URLEncoding .DecodeString (file .Name ())
87
+ fileName := string (decodedFileName )
88
+ if ! strings .HasPrefix (fileName , "http" ) {
85
89
continue
86
90
}
87
- path , err := url .PathUnescape (file . Name () )
91
+ path , err := url .PathUnescape (fileName )
88
92
if err != nil {
89
93
c .Log .Warn (err )
90
94
}
@@ -96,7 +100,7 @@ func (c *Indexes) List(context.Context) ([]string, error) {
96
100
97
101
// Remove deletes the index file from the Indexes Folder
98
102
func (c * Indexes ) Remove (ctx context.Context , payload * indexes.IndexPayload ) (* indexes.Operation , error ) {
99
- filename := url .PathEscape (payload .URL )
103
+ filename := b64 . StdEncoding . EncodeToString ([] byte ( url .PathEscape (payload .URL )) )
100
104
err := os .RemoveAll (filepath .Join (c .Folder , filename ))
101
105
if err != nil {
102
106
return nil , err
0 commit comments