@@ -76,13 +76,13 @@ public function writePackage(AssetPackage $package)
76
76
];
77
77
$ json = Json::encode ($ data );
78
78
$ hash = hash ('sha256 ' , $ json );
79
- $ path = $ this ->buildPackagePath ($ name , $ hash );
79
+ $ path = $ this ->buildHashedPath ($ name , $ hash );
80
80
if (!file_exists ($ path )) {
81
81
$ this ->getLocker ()->lock ();
82
82
{
83
83
static ::mkdir (dirname ($ path ));
84
84
file_put_contents ($ path , $ json );
85
- file_put_contents ($ this ->buildPackagePath ($ name ), $ json );
85
+ file_put_contents ($ this ->buildHashedPath ($ name ), $ json );
86
86
$ this ->writeProviderLatest ($ name , $ hash );
87
87
}
88
88
$ this ->getLocker ()->release ();
@@ -94,7 +94,7 @@ public function writePackage(AssetPackage $package)
94
94
public function readPackage (AssetPackage $ package )
95
95
{
96
96
$ name = $ package ->getFullName ();
97
- $ path = $ this ->buildPackagePath ($ name );
97
+ $ path = $ this ->buildHashedPath ($ name );
98
98
if (!file_exists ($ path )) {
99
99
return [];
100
100
}
@@ -114,14 +114,14 @@ public function buildPath()
114
114
return implode (DIRECTORY_SEPARATOR , $ args );
115
115
}
116
116
117
- public function buildPackagePath ($ name , $ hash = 'latest ' )
117
+ public function buildHashedPath ($ name , $ hash = 'latest ' )
118
118
{
119
119
return $ this ->buildPath ('p ' , $ name , $ hash . '.json ' );
120
120
}
121
121
122
122
protected function writeProviderLatest ($ name , $ hash )
123
123
{
124
- $ latest_path = $ this ->buildPath ('provider-latest.json ' );
124
+ $ latest_path = $ this ->buildHashedPath ('provider-latest ' );
125
125
if (file_exists ($ latest_path )) {
126
126
$ data = Json::decode (file_get_contents ($ latest_path ) ?: '[] ' );
127
127
}
@@ -134,12 +134,13 @@ protected function writeProviderLatest($name, $hash)
134
134
$ data ['providers ' ][$ name ] = ['sha256 ' => $ hash ];
135
135
$ json = Json::encode ($ data );
136
136
$ hash = hash ('sha256 ' , $ json );
137
- $ path = $ this ->buildPath ( ' p ' , " provider-latest$ $ hash.json " );
137
+ $ path = $ this ->buildHashedPath ( ' provider-latest ' , $ hash );
138
138
if (!file_exists ($ path )) {
139
139
$ this ->getLocker ()->lock ();
140
140
{
141
+ static ::mkdir (dirname ($ path ));
141
142
file_put_contents ($ path , $ json );
142
- file_put_contents ($ latest_path , Json:: encode ( $ data ) );
143
+ file_put_contents ($ latest_path , $ json );
143
144
$ this ->writePackagesJson ($ hash );
144
145
}
145
146
$ this ->getLocker ()->release ();
@@ -154,7 +155,7 @@ protected function writePackagesJson($hash)
154
155
'search ' => '/search.json?q=%query% ' ,
155
156
'providers-url ' => '/p/%package%/%hash%.json ' ,
156
157
'provider-includes ' => [
157
- 'p/provider-latest$ %hash%.json ' => [
158
+ 'p/provider-latest/ %hash%.json ' => [
158
159
'sha256 ' => $ hash ,
159
160
],
160
161
],
0 commit comments