@@ -138,20 +138,16 @@ private async Task<string> GetVVMModelPathForMobile()
138138 var bundlePath = Foundation . NSBundle . MainBundle . BundlePath ;
139139 var sourceModelPath = Path . Combine ( bundlePath , "models" , "vvms" ) ;
140140
141- if ( ! Directory . Exists ( destDir ) )
142- {
143- await CopyAccessibleDirectory ( sourceModelPath , destDir ) ;
144- }
141+ // TODO: .done みたいなファイルを置いたりして、何度もコピーを走らせないようにしたりするとよさそう
142+ await CopyAccessibleDirectory ( sourceModelPath , destDir ) ;
145143
146144 return destDir ;
147145#elif ANDROID
148146 var filesDir = Android . App . Application . Context . FilesDir . AbsolutePath ;
149147 var destDir = Path . Combine ( filesDir , "models" , "vvms" ) ;
150148
151- if ( ! Directory . Exists ( destDir ) )
152- {
153- await CopyAccessibleDirectory ( "models/vvms" , destDir ) ;
154- }
149+ // TODO: .done みたいなファイルを置いたりして、何度もコピーを走らせないようにしたりするとよさそう
150+ await CopyAccessibleDirectory ( "models/vvms" , destDir ) ;
155151
156152 return destDir ;
157153#else
@@ -203,10 +199,8 @@ private async Task LoadVVMModels(string directoryPath)
203199 var bundlePath = Foundation . NSBundle . MainBundle . BundlePath ;
204200 var sourceDictPath = Path . Combine ( bundlePath , "dict" , "open_jtalk_dic_utf_8-1.11" ) ;
205201
206- if ( ! Directory . Exists ( destDir ) )
207- {
208- await CopyAccessibleDirectory ( sourceDictPath , destDir ) ;
209- }
202+ // TODO: .done みたいなファイルを置いたりして、何度もコピーを走らせないようにしたりするとよさそう
203+ await CopyAccessibleDirectory ( sourceDictPath , destDir ) ;
210204
211205 return destDir ;
212206#elif ANDROID
@@ -215,10 +209,8 @@ private async Task LoadVVMModels(string directoryPath)
215209 var filesDir = context . FilesDir . AbsolutePath ;
216210 var destDir = Path . Combine ( filesDir , "open_jtalk_dic" ) ;
217211
218- if ( ! Directory . Exists ( destDir ) )
219- {
220- await CopyAccessibleDirectory ( "dict/open_jtalk_dic_utf_8-1.11" , destDir ) ;
221- }
212+ // TODO: .done みたいなファイルを置いたりして、何度もコピーを走らせないようにしたりするとよさそう
213+ await CopyAccessibleDirectory ( "dict/open_jtalk_dic_utf_8-1.11" , destDir ) ;
222214
223215 return destDir ;
224216#else
@@ -237,13 +229,19 @@ private async Task LoadVVMModels(string directoryPath)
237229 /// </summary>
238230 private async Task CopyAccessibleDirectory ( string sourceDir , string targetDir )
239231 {
240- #if IOS || ANDROID
241- Directory . CreateDirectory ( targetDir ) ;
232+ #if IOS
242233 if ( ! Directory . Exists ( sourceDir ) )
243234 {
244235 throw new FileNotFoundException ( $ "source directory not found: { sourceDir } ") ;
245236 }
246237
238+ await CopyDirectory ( sourceDir , targetDir ) ;
239+ #elif ANDROID
240+ if ( Android . App . Application . Context . Assets ? . List ( sourceDir ) is null )
241+ {
242+ throw new FileNotFoundException ( $ "source directory not found: { sourceDir } ") ;
243+ }
244+
247245 await CopyDirectory ( sourceDir , targetDir ) ;
248246#else
249247 throw new PlatformNotSupportedException ( ) ;
0 commit comments