@@ -1156,6 +1156,31 @@ func TestReindexDirectorySimple(t *testing.T) {
1156
1156
if err != nil {
1157
1157
t .Fatal (err )
1158
1158
}
1159
+
1160
+ // What happens if we inject a ..links file in there?
1161
+ lpath := filepath .Join (v_path , linksFileName )
1162
+ err = os .WriteFile (lpath , []byte {}, 0644 )
1163
+ if err != nil {
1164
+ t .Fatal (err )
1165
+ }
1166
+
1167
+ lpath2 := filepath .Join (v_path , "moves" , "electric" , linksFileName )
1168
+ err = os .WriteFile (lpath2 , []byte {}, 0644 )
1169
+ if err != nil {
1170
+ t .Fatal (err )
1171
+ }
1172
+
1173
+ err = reindexDirectory (reg , project , asset , version )
1174
+ if err != nil {
1175
+ t .Fatalf ("failed to reindex directory; %v" , err )
1176
+ }
1177
+
1178
+ if _ , err := os .Stat (lpath ); err == nil || ! errors .Is (err , os .ErrNotExist ) {
1179
+ t .Error ("expected existing ..links file to be deleted" )
1180
+ }
1181
+ if _ , err := os .Stat (lpath2 ); err == nil || ! errors .Is (err , os .ErrNotExist ) {
1182
+ t .Error ("expected existing nested ..links file to be deleted" )
1183
+ }
1159
1184
}
1160
1185
1161
1186
func TestReindexDirectorySkipHidden (t * testing.T ) {
@@ -1314,6 +1339,17 @@ func TestReindexDirectoryRegistryLinks(t *testing.T) {
1314
1339
if err != nil {
1315
1340
t .Fatal (err )
1316
1341
}
1342
+
1343
+ // Confirming that we have ..links files.
1344
+ _ , found := recovered [linksFileName ]
1345
+ if ! found {
1346
+ t .Error ("missing a top-level ..links file" )
1347
+ }
1348
+
1349
+ _ , found = recovered [filepath .Join ("moves" , "electric" , linksFileName )]
1350
+ if ! found {
1351
+ t .Error ("missing a nested ..links file" )
1352
+ }
1317
1353
}
1318
1354
1319
1355
func TestReindexDirectoryRegistryLinkFailures (t * testing.T ) {
0 commit comments