@@ -159,7 +159,7 @@ func TestFolderCreationTracker_directoryExists(t *testing.T) {
159159 }) // "create" our folder
160160 err := fct .CreateFolder (folderExists , func () error {
161161 return common.FolderCreationErrorAlreadyExists {}
162- }) // fail creation on not existing
162+ }) // fail creation on not existing
163163 a .NoError (err , "already exists should be caught" ) // ensure we caught that error
164164 expectedFailureErr := errors .New ("this creation should fail" )
165165 err = fct .CreateFolder (folderShouldCreate , func () error {
@@ -194,3 +194,45 @@ func TestFolderCreationTracker_directoryExists(t *testing.T) {
194194
195195 a .NoError (err )
196196}
197+
198+ // Verifies that a subsequent call to createFolder does not panic when the status is
199+ // SkippedEntityAlreadyExists
200+ func TestFolderCreationTracker_skippedEntityExits (t * testing.T ) {
201+ a := assert .New (t )
202+
203+ folderExists := "folderExists"
204+ existsIdx := JpptFolderIndex {0 , 0 }
205+
206+ plan := & mockedJobPlan {
207+ transfers : map [JpptFolderIndex ]* JobPartPlanTransfer {
208+ existsIdx : {atomicTransferStatus : common .ETransferStatus .NotStarted ()},
209+ },
210+ }
211+
212+ fct := & jpptFolderTracker {
213+ fetchTransfer : plan .getFetchTransfer (t ),
214+ mu : & sync.Mutex {},
215+ contents : make (map [string ]* JpptFolderTrackerState ),
216+ }
217+
218+ fct .RegisterPropertiesTransfer (folderExists , existsIdx .PartNum , existsIdx .TransferIndex )
219+ err := fct .CreateFolder (folderExists , func () error {
220+ return common.FolderCreationErrorAlreadyExists {}
221+ })
222+ a .NoError (err , "already exists should be caught" )
223+ a .Equal (common .ETransferStatus .FolderExisted (), plan .transfers [existsIdx ].TransferStatus ())
224+
225+ // Simulate folder transfer setting properties this happens in any_toremotefolder
226+ plan .transfers [existsIdx ].SetTransferStatus (common .ETransferStatus .SkippedEntityAlreadyExists (), false )
227+
228+ folderCreated := false
229+ a .NotPanics (func () { // Subsequent call to createFolder should not panic
230+ err = fct .CreateFolder (folderExists , func () error {
231+ folderCreated = true
232+ return nil
233+ })
234+ })
235+ a .NoError (err )
236+ a .False (folderCreated , "createFolder should return early without calling doCreation" )
237+
238+ }
0 commit comments