@@ -65,34 +65,41 @@ class AzureTargetStorage(private val config: AzureConfig) : TargetStorage {
65
65
containerClient = serviceClient.getBlobContainerClient(container)
66
66
}
67
67
68
- override suspend fun status (path : Path ): TargetStorage .PathStatus ? {
69
- return try {
70
- TargetStorage .PathStatus (blob(path)
68
+ override suspend fun status (path : Path ): TargetStorage .PathStatus ? =
69
+ withContext(Dispatchers .IO ) {
70
+ try {
71
+ TargetStorage .PathStatus (blob(path)
71
72
.getPropertiesWithResponse(null , null , null )
72
73
.value
73
74
.blobSize)
74
- } catch (ex: Exception ) {
75
- null
75
+ } catch (ex: Exception ) {
76
+ null
77
+ }
76
78
}
77
- }
78
79
79
80
@Throws(IOException ::class )
80
- override suspend fun newInputStream (path : Path ): InputStream = blob(path).openInputStream()
81
+ override suspend fun newInputStream (path : Path ): InputStream = withContext(Dispatchers .IO ) {
82
+ blob(path).openInputStream()
83
+ }
81
84
82
85
@Throws(IOException ::class )
83
- override suspend fun move (oldPath : Path , newPath : Path ) {
86
+ override suspend fun move (oldPath : Path , newPath : Path ) = withContext( Dispatchers . IO ) {
84
87
blob(newPath).copyFromUrl(" ${config.endpoint} /${config.container} /${oldPath.toKey()} " )
85
- delete (oldPath)
88
+ doDelete (oldPath)
86
89
}
87
90
88
91
@Throws(IOException ::class )
89
- override suspend fun store (localPath : Path , newPath : Path ) {
92
+ override suspend fun store (localPath : Path , newPath : Path ) = withContext( Dispatchers . IO ) {
90
93
blob(newPath).uploadFromFile(localPath.toString(), true )
91
94
localPath.deleteExisting()
92
95
}
93
96
94
97
@Throws(IOException ::class )
95
- override suspend fun delete (path : Path ) {
98
+ override suspend fun delete (path : Path ) = withContext(Dispatchers .IO ) {
99
+ doDelete(path)
100
+ }
101
+
102
+ private fun doDelete (path : Path ) {
96
103
blob(path).delete()
97
104
}
98
105
0 commit comments