@@ -140,6 +140,7 @@ func validateDirModels(
140
140
if err != nil {
141
141
return nil , err
142
142
}
143
+ dirPrefix = s .EnsureSuffix (dirPrefix , "/" )
143
144
144
145
s3Objects , err := awsClientForBucket .ListS3PathDir (modelPath , false , nil )
145
146
if err != nil {
@@ -152,6 +153,7 @@ func validateDirModels(
152
153
if err != nil {
153
154
return nil , err
154
155
}
156
+ dirPrefix = s .EnsureSuffix (dirPrefix , "/" )
155
157
156
158
gcsObjects , err := gcpClient .ListGCSPathDir (modelPath , nil )
157
159
if err != nil {
@@ -162,6 +164,12 @@ func validateDirModels(
162
164
if len (modelDirPaths ) == 0 {
163
165
return nil , errorForPredictorType (dirPrefix , modelDirPaths )
164
166
}
167
+ if len (modelDirPaths ) != len (slices .RemoveIfHasString (modelDirPaths , dirPrefix )) {
168
+ return nil , ErrorObjectConflictingWithPrefix (dirPrefix )
169
+ }
170
+ if len (modelDirPaths ) != len (slices .RemoveIfHasString (modelDirPaths , strings .TrimRight (dirPrefix , "/" ))) {
171
+ return nil , ErrorObjectConflictingWithPrefix (strings .TrimRight (dirPrefix , "/" ))
172
+ }
165
173
166
174
modelNames := []string {}
167
175
modelDirPathLength := len (slices .RemoveEmpties (strings .Split (dirPrefix , "/" )))
@@ -179,7 +187,13 @@ func validateDirModels(
179
187
}
180
188
181
189
modelPrefix := filepath .Join (dirPrefix , modelName )
190
+ if len (modelDirPaths ) != len (slices .RemoveIfHasString (modelDirPaths , modelPrefix )) {
191
+ return nil , ErrorObjectConflictingWithPrefix (modelPrefix )
192
+ }
182
193
modelPrefix = s .EnsureSuffix (modelPrefix , "/" )
194
+ if len (modelDirPaths ) != len (slices .RemoveIfHasString (modelDirPaths , modelPrefix )) {
195
+ return nil , ErrorObjectConflictingWithPrefix (modelPrefix )
196
+ }
183
197
184
198
modelStructureType := determineBaseModelStructure (modelDirPaths , modelPrefix )
185
199
if modelStructureType == userconfig .UnknownModelStructureType {
@@ -296,6 +310,12 @@ func validateModels(
296
310
if len (modelPaths ) == 0 {
297
311
return nil , errors .Wrap (errorForPredictorType (modelPrefix , modelPaths ), modelNameWrapStr )
298
312
}
313
+ if len (modelPaths ) != len (slices .RemoveIfHasString (modelPaths , modelPrefix )) {
314
+ return nil , ErrorObjectConflictingWithPrefix (modelPrefix )
315
+ }
316
+ if len (modelPaths ) != len (slices .RemoveIfHasString (modelPaths , strings .TrimRight (modelPrefix , "/" ))) {
317
+ return nil , ErrorObjectConflictingWithPrefix (strings .TrimRight (modelPrefix , "/" ))
318
+ }
299
319
300
320
modelStructureType := determineBaseModelStructure (modelPaths , modelPrefix )
301
321
if modelStructureType == userconfig .UnknownModelStructureType {
0 commit comments