@@ -698,3 +698,34 @@ async def test_upload_to_multiple_locations(
698698 ".cloud_backup" : copy_backup ,
699699 }
700700 assert coresys .backups .get ("7fed74c8" ).location is None
701+
702+
703+ async def test_upload_duplicate_backup_new_location (
704+ api_client : TestClient ,
705+ coresys : CoreSys ,
706+ tmp_supervisor_data : Path ,
707+ ):
708+ """Test uploading a backup that already exists to a new location."""
709+ backup_file = get_fixture_path ("backup_example.tar" )
710+ orig_backup = Path (copy (backup_file , coresys .config .path_backup ))
711+ await coresys .backups .reload (None , "backup_example.tar" )
712+ assert coresys .backups .get ("7fed74c8" ).all_locations == {None : orig_backup }
713+
714+ with backup_file .open ("rb" ) as file , MultipartWriter ("form-data" ) as mp :
715+ mp .append (file )
716+ resp = await api_client .post (
717+ "/backups/new/upload?location=.cloud_backup" , data = mp
718+ )
719+
720+ assert resp .status == 200
721+ body = await resp .json ()
722+ assert body ["data" ]["slug" ] == "7fed74c8"
723+
724+ copy_backup = coresys .config .path_core_backup / "7fed74c8.tar"
725+ assert orig_backup .exists ()
726+ assert copy_backup .exists ()
727+ assert coresys .backups .get ("7fed74c8" ).all_locations == {
728+ None : orig_backup ,
729+ ".cloud_backup" : copy_backup ,
730+ }
731+ assert coresys .backups .get ("7fed74c8" ).location is None
0 commit comments