1// @ts-nocheck 2/* 3 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import fileIO from '@ohos.fileio'; 18import { stashOrGetObject } from '../utils/SingleInstanceUtils'; 19import { Log } from '../utils/Log'; 20import { hiSysEventDataQueryTimedOut } from '../utils/hisysEventUtil'; 21import photoAccessHelper from '@ohos.file.photoAccessHelper'; 22import dataSharePredicates from '@ohos.data.dataSharePredicates'; 23import { MediaConstants } from '../constants/MediaConstants' 24import { getSystemAlbumDisplayName } from './UserFileDataHelper'; 25import { SimpleAlbumDataItem } from '../common/SimpleAlbumDataItem'; 26 27const TAG = 'UserFileModel'; 28 29export class UserFileModelItem { 30 fileAsset: photoAccessHelper.PhotoAsset; 31 counts: number; 32} 33 34class UserFileModel { 35 private userFileMgr: photoAccessHelper.PhotoAccessHelper = undefined; 36 37 constructor() { 38 } 39 40 onCreate(context): void { 41 if (this.userFileMgr == undefined) { 42 this.userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); 43 } 44 } 45 46 getUserFileMgr(): photoAccessHelper.PhotoAccessHelper { 47 return this.userFileMgr; 48 } 49 50 async createOne(displayName: string, albumUri: string): Promise<photoAccessHelper.PhotoAsset> { 51 Log.info(TAG, 'createOne displayName:' + displayName + ' albumUri: ' + albumUri); 52 let fileAsset = await this.userFileMgr.createAsset(displayName, albumUri); 53 let album = await this.getUserAlbumItemByUri(albumUri); 54 await album.addAssets([fileAsset]); 55 return fileAsset; 56 } 57 58 async getUserAlbumItemByUri(uri: string): Promise<photoAccessHelper.Album> { 59 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; 60 let album: photoAccessHelper.Album = null; 61 try { 62 Log.info(TAG, 'getUserAlbumItemByUri'); 63 let predicates = new dataSharePredicates.DataSharePredicates(); 64 predicates.equalTo(photoAccessHelper.AlbumKeys.URI, uri); 65 let fetchOptions = { 66 fetchColumns: MediaConstants.EMPTY_FETCH_COLUMNS, 67 predicates: predicates 68 }; 69 fetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 70 Log.info(TAG, 'get Album fetchResult, count: ' + fetchResult.getCount()); 71 if (fetchResult.getCount() > 0) { 72 album = fetchResult.getFirstObject(); 73 } 74 } catch (err) { 75 Log.error(TAG, 'get Album fetchResult failed with err: ' + err); 76 } finally { 77 if (fetchResult != null) { 78 fetchResult.close(); 79 } 80 } 81 return album; 82 } 83 84 async copyOne(source: photoAccessHelper.PhotoAsset, target: photoAccessHelper.PhotoAsset): Promise<void> { 85 Log.info(TAG, 'copy start: src:' + source.uri + ' target: ' + target.uri); 86 let fd: Number = await this.openAsset('R', source); 87 if (fd <= 0) { 88 throw new Error('fd is invalid'); 89 } 90 91 let targetFd: Number = await this.openAsset('RW', target); 92 if (targetFd <= 0) { 93 throw new Error('targetFd is invalid'); 94 } 95 96 await fileIO.copyFile(fd, targetFd); 97 98 await this.closeAsset(fd, source); 99 await this.closeAsset(targetFd, target); 100 101 Log.debug(TAG, 'copy end'); 102 } 103 104 async deleteOne(uri: string): Promise<void> { 105 Log.debug(TAG, 'deleteAsset uri: ' + uri); 106 try { 107 await this.userFileMgr.deleteAssets([uri]); 108 } catch (err) { 109 Log.error(TAG, 'deleteOne with error: ' + err); 110 } 111 } 112 113 async recover(fileAsset: photoAccessHelper.PhotoAsset): Promise<void> { 114 let albumFetchResult = null; 115 try { 116 Log.debug(TAG, 'recoverPhotoAssetsDemoPromise:' + fileAsset.displayName); 117 albumFetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 118 let album = await albumFetchResult.getFirstObject(); 119 Log.debug(TAG, 'album get'); 120 album.recoverAssets([fileAsset]).then(() => { 121 Log.debug(TAG, 'album recoverPhotoAssets successfully'); 122 }).catch((err) => { 123 Log.info(TAG, 'album recoverPhotoAssets failed with error: ' + err); 124 }); 125 } catch (err) { 126 Log.error(TAG, 'recoverPhotoAssetsDemoPromise failed with error: ' + err); 127 } finally { 128 if (albumFetchResult != null) { 129 albumFetchResult.close(); 130 } 131 } 132 } 133 134 async permanentDelete(fileAsset: photoAccessHelper.PhotoAsset): Promise<void> { 135 let albumFetchResult = null; 136 try { 137 Log.debug(TAG, 'permanentDelete'); 138 albumFetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 139 let album = await albumFetchResult.getFirstObject(); 140 album.deleteAssets([fileAsset]).then(() => { 141 Log.debug('album deletePhotoAssets successfully'); 142 }).catch((err) => { 143 Log.error(TAG, 'album deletePhotoAssets failed with error: ' + err); 144 }); 145 } catch (err) { 146 Log.error(TAG, 'permanentDelete failed with error: ' + err); 147 } finally { 148 if (albumFetchResult != null) { 149 albumFetchResult.close(); 150 } 151 } 152 } 153 154 async createAlbum(albumName: string): Promise<SimpleAlbumDataItem> { 155 let newAlbum: SimpleAlbumDataItem = undefined; 156 try { 157 let album = await this.userFileMgr.createAlbum(albumName); 158 newAlbum = new SimpleAlbumDataItem(MediaConstants.ALBUM_ID_USER, albumName, album.albumUri, 159 '', '', MediaConstants.ALBUM_TYPE_USER, MediaConstants.ALBUM_SUBTYPE_USER_GENERIC); 160 } catch (err) { 161 Log.error(TAG, 'createAlbum failed with error: ' + err); 162 } 163 return newAlbum; 164 } 165 166 async deleteAlbum(albumName: string): Promise<void> { 167 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; 168 try { 169 let predicates = new dataSharePredicates.DataSharePredicates(); 170 predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, albumName); 171 let fetchOptions = { 172 fetchColumns: MediaConstants.EMPTY_FETCH_COLUMNS, 173 predicates: predicates 174 }; 175 fetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 176 for (let i = 0; i < fetchResult.getCount(); i++) { 177 let albumAsset = await fetchResult.getObjectByPosition(i); 178 Log.info(TAG, 'deleteAlbum albumUri' + albumAsset.albumUri); 179 Log.info(TAG, 'deleteAlbum albumName' + albumAsset.albumName); 180 this.userFileMgr.deleteAlbums([albumAsset]).then(() => { 181 Log.info(TAG, 'deletePhotoAlbumsPromise successfully'); 182 }).catch((err) => { 183 Log.error(TAG, 'deletePhotoAlbumsPromise failed with err: ' + err); 184 }); 185 } 186 } catch (err) { 187 Log.error(TAG, 'deletePhotoAlbumsPromise failed with error: ' + err); 188 } finally { 189 if (fetchResult != null) { 190 fetchResult.close(); 191 } 192 } 193 } 194 195 async deleteAll(fetchOption: photoAccessHelper.FetchOptions): Promise<void> { 196 Log.info(TAG, 'deleteAll'); 197 let fetchFileResult: photoAccessHelper.FetchResult = null; 198 try { 199 fetchFileResult = await this.userFileMgr.getAssets(fetchOption); 200 Log.debug(TAG, 'deleteAll getPhotoAssets'); 201 let deleteAllGetAllObject = hiSysEventDataQueryTimedOut('deleteAllGetAllObject'); 202 let fileAssets: photoAccessHelper.PhotoAsset[] = await fetchFileResult.getAllObject(); 203 clearTimeout(deleteAllGetAllObject); 204 for (let i = 0;i < fileAssets.length; i++) { 205 await this.deleteOne(fileAssets[i].uri); 206 } 207 Log.debug(TAG, 'deleteAll getFirstObject'); 208 } catch (err) { 209 Log.error(TAG, 'deleteAll error:' + JSON.stringify(err)); 210 } finally { 211 if (fetchFileResult != null) { 212 fetchFileResult.close(); 213 } 214 } 215 Log.debug(TAG, 'deleteAll finish'); 216 } 217 218 async getAllMediaItems(): Promise<photoAccessHelper.PhotoAsset[]> { 219 let fileAssets: photoAccessHelper.PhotoAsset[] = []; 220 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null; 221 try { 222 let predicates = new dataSharePredicates.DataSharePredicates(); 223 predicates.orderByDesc(photoAccessHelper.PhotoKeys.DATE_ADDED); 224 let emptyFetchOption = { 225 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 226 predicates: predicates 227 }; 228 photoFetchResult = await this.userFileMgr.getAssets(emptyFetchOption); 229 Log.info(TAG, 'getAllMediaItems count: ' + photoFetchResult.getCount()); 230 for (let i = 0;i < photoFetchResult.getCount(); i++) { 231 fileAssets.push(await photoFetchResult.getObjectByPosition(i)); 232 } 233 } catch (err) { 234 Log.error(TAG, 'getAllMediaItems failed with err: ' + err); 235 } finally { 236 if (photoFetchResult != null) { 237 photoFetchResult.close(); 238 } 239 } 240 return fileAssets; 241 } 242 243 async getAllMovingPhotoItems(): Promise<photoAccessHelper.PhotoAsset[]> { 244 let fileAssets: photoAccessHelper.PhotoAsset[] = []; 245 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null; 246 try { 247 let predicates = new dataSharePredicates.DataSharePredicates(); 248 predicates.equalTo(MediaConstants.PHOTO_SUBTYPE, MediaConstants.MOVING_PHOTO); 249 predicates.orderByDesc(photoAccessHelper.PhotoKeys.DATE_ADDED); 250 let fetchOptions: photoAccessHelper.FetchOptions = { 251 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 252 predicates: predicates 253 }; 254 photoFetchResult = await this.userFileMgr.getAssets(fetchOptions); 255 Log.info(TAG, 'getAllMovingPhotoItems count: ' + photoFetchResult.getCount()); 256 for (let i = 0; i < photoFetchResult.getCount(); i++) { 257 fileAssets.push(await photoFetchResult.getObjectByPosition(i)); 258 } 259 } catch (err) { 260 Log.error(TAG, 'getAllMovingPhotoItems failed with err: ' + err); 261 } finally { 262 if (photoFetchResult != null) { 263 photoFetchResult.close(); 264 } 265 } 266 return fileAssets; 267 } 268 269 async getAllMediaItemsByType(type: number, subType: number, albumFetchOption, fileFetchOption): Promise<photoAccessHelper.PhotoAsset[]> { 270 let fileAssets: photoAccessHelper.PhotoAsset[] = []; 271 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; 272 try { 273 Log.info(TAG, 'getAllMediaItemsByUserFile'); 274 Log.info(TAG, 'type:' + type); 275 Log.info(TAG, 'subType:' + subType); 276 if (type === photoAccessHelper.AlbumType.USER && albumFetchOption != null) { 277 Log.info(TAG, 'albumFetchOption != null'); 278 fetchResult = await this.userFileMgr.getAlbums(type, subType, albumFetchOption); 279 } else { 280 fetchResult = await this.userFileMgr.getAlbums(type, subType); 281 } 282 Log.info(TAG, 'get Album fetchResult, count: ' + fetchResult.getCount()); 283 for (let i = 0; i < fetchResult.getCount(); i++) { 284 let albumAsset: photoAccessHelper.Album = await fetchResult.getObjectByPosition(i); 285 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null; 286 try { 287 photoFetchResult = await albumAsset.getAssets(fileFetchOption); 288 for (let i = 0; i < photoFetchResult.getCount(); i++) { 289 let photoAsset = await photoFetchResult.getObjectByPosition(i); 290 fileAssets.push(photoAsset); 291 Log.info(TAG, 'getPhotoAssets successfully, file displayName: ' + photoAsset.displayName); 292 } 293 } catch (err) { 294 Log.info(TAG, 'get Album getPhotoAssets failed with err: ' + err); 295 } finally { 296 if (photoFetchResult != null) { 297 photoFetchResult.close(); 298 } 299 } 300 } 301 } catch (err) { 302 Log.error(TAG, 'get Album fetchResult failed with err: ' + err); 303 } finally { 304 if (fetchResult != null) { 305 fetchResult.close(); 306 } 307 } 308 Log.info(TAG, 'fileAssets: ' + fileAssets.length); 309 return fileAssets; 310 } 311 312 async getMediaItemByUriFromTrash(uri: string): Promise<photoAccessHelper.PhotoAsset> { 313 Log.info(TAG, 'getMediaItemByUriFromTrash'); 314 Log.info(TAG, 'uri:' + uri); 315 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; 316 let fileAsset: photoAccessHelper.PhotoAsset = null; 317 try { 318 albumFetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 319 let albumAsset = await albumFetchResult.getFirstObject(); 320 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null; 321 try { 322 let predicates = new dataSharePredicates.DataSharePredicates(); 323 let emptyFetchOption = { 324 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 325 predicates: predicates 326 }; 327 photoFetchResult = await albumAsset.getAssets(emptyFetchOption); 328 for (let i = 0; i < photoFetchResult.getCount(); i++) { 329 let photoAsset = await photoFetchResult.getObjectByPosition(i); 330 if (photoAsset.uri === uri) { 331 fileAsset = photoAsset; 332 Log.info(TAG, 'getMediaItemByUriFromTrash success: ' + photoAsset.displayName); 333 break; 334 } 335 } 336 } catch (err) { 337 Log.info(TAG, 'getMediaItemByUriFromTrash getPhotoAssets failed with err: ' + err); 338 } finally { 339 if (photoFetchResult != null) { 340 photoFetchResult.close(); 341 } 342 } 343 } catch (err) { 344 Log.error(TAG, 'getMediaItemByUriFromTrash failed with error: ' + err); 345 } finally { 346 if (albumFetchResult != null) { 347 albumFetchResult.close(); 348 } 349 } 350 return fileAsset; 351 } 352 353 async getMediaItemByUri(uri: string): Promise<photoAccessHelper.PhotoAsset> { 354 Log.info(TAG, 'getMediaItemByUri'); 355 Log.info(TAG, 'uri:' + uri); 356 let predicates = new dataSharePredicates.DataSharePredicates(); 357 predicates.equalTo(photoAccessHelper.PhotoKeys.URI, uri); 358 let fetchOptions = { 359 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 360 predicates: predicates 361 }; 362 let fileAsset: photoAccessHelper.PhotoAsset = null; 363 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null 364 try { 365 Log.info(TAG, 'fetchResult start'); 366 fetchResult = await this.userFileMgr.getAssets(fetchOptions); 367 Log.info(TAG, 'fetchResult count ' + fetchResult.getCount()); 368 fileAsset = await fetchResult.getFirstObject(); 369 Log.info(TAG, 'fileAsset ' + fileAsset.displayName); 370 } catch (err) { 371 Log.error(TAG, 'getMediaItemByUri failed, message = ' + err); 372 } finally { 373 if (fetchResult != null) { 374 fetchResult.close(); 375 } 376 } 377 return fileAsset; 378 } 379 380 async getMediaItemCountsByDisplayName(displayName: string): Promise<number> { 381 Log.info(TAG, 'getMediaItemCountsByDisplayName'); 382 let count = 0; 383 let fetchFileResult: photoAccessHelper.FetchResult = null; 384 let predicates = new dataSharePredicates.DataSharePredicates(); 385 predicates.equalTo(photoAccessHelper.PhotoKeys.DISPLAY_NAME, displayName); 386 let fetchOptions = { 387 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 388 predicates: predicates 389 }; 390 try { 391 fetchFileResult = await this.userFileMgr.getAssets(fetchOptions); 392 Log.debug(TAG, 'getMediaItemCountsByDisplayName getPhotoAssets'); 393 count = await fetchFileResult.getCount(); 394 } catch (err) { 395 Log.error(TAG, 'getMediaItemCountsByDisplayName error:' + JSON.stringify(err)); 396 } finally { 397 if (fetchFileResult != null) { 398 fetchFileResult.close(); 399 } 400 } 401 Log.debug(TAG, 'getMediaItemCountsByDisplayName finish'); 402 return count; 403 } 404 405 async getUserAlbumCountByName(albumName: string): Promise<number> { 406 Log.info(TAG, 'getUserAlbumCountByName'); 407 Log.info(TAG, 'album_name:' + albumName); 408 let count = 0; 409 let systemAlbums = await getSystemAlbumDisplayName(); 410 if (systemAlbums.indexOf(albumName) >= 0) { 411 return 1; 412 } 413 let fetchResult: photoAccessHelper.FetchResult = null; 414 try { 415 let predicates = new dataSharePredicates.DataSharePredicates(); 416 predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, albumName); 417 let fetchOptions = { 418 fetchColumns: MediaConstants.EMPTY_FETCH_COLUMNS, 419 predicates: predicates 420 }; 421 fetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 422 Log.info(TAG, 'fetchResult' + fetchResult.getCount()); 423 count = fetchResult.getCount(); 424 } catch (err) { 425 Log.error(TAG, 'getUserAlbumCountByName error:' + JSON.stringify(err)); 426 } finally { 427 if (fetchResult != null) { 428 fetchResult.close(); 429 } 430 } 431 Log.debug(TAG, 'getUserAlbumCountByName finish'); 432 return count; 433 } 434 435 async getActivePeers(): Promise<photoAccessHelper.PeerInfo[]> { 436 Log.info(TAG, 'getActivePeers'); 437 let peers: photoAccessHelper.PeerInfo[] = []; 438 try { 439 let getActivePeers = hiSysEventDataQueryTimedOut('getActivePeers') 440 peers = await this.userFileMgr.getActivePeers(); 441 clearTimeout(getActivePeers); 442 } catch (err) { 443 Log.error(TAG, 'getActivePeers error:' + JSON.stringify(err)); 444 } 445 Log.debug(TAG, 'getActivePeers finish'); 446 return peers; 447 } 448 449 async getUserAlbumByName(albumName: string): Promise<photoAccessHelper.Album> { 450 Log.info(TAG, 'getUserAlbumByName'); 451 Log.info(TAG, 'album_name' + albumName); 452 let fetchResult: photoAccessHelper.FetchResult = null; 453 let album = null; 454 try { 455 let predicates = new dataSharePredicates.DataSharePredicates(); 456 predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, albumName); 457 let fetchOptions = { 458 fetchColumns: MediaConstants.EMPTY_FETCH_COLUMNS, 459 predicates: predicates 460 }; 461 fetchResult = await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 462 Log.info(TAG, 'fetchResult' + fetchResult.getCount()); 463 if (fetchResult.getCount() > 0) { 464 album = fetchResult.getFirstObject(); 465 } 466 } catch (err) { 467 Log.error(TAG, 'getUserAlbumByName error:' + JSON.stringify(err)); 468 } finally { 469 if (fetchResult != null) { 470 fetchResult.close(); 471 } 472 } 473 Log.debug(TAG, 'getUserAlbumByName finish'); 474 return album; 475 } 476 477 async getAlbums(fetchOption: photoAccessHelper.FetchOptions): Promise<photoAccessHelper.Album[]> { 478 Log.info(TAG, 'getAlbums'); 479 let albums: photoAccessHelper.Album[] = []; 480 try { 481 albums = await this.userFileMgr.getAlbums(fetchOption); 482 Log.info(TAG, 'getAlbums albums ' + albums.getCounts()); 483 } catch (err) { 484 Log.error(TAG, 'getAlbums error:' + JSON.stringify(err)); 485 } 486 Log.debug(TAG, 'getAlbums finish'); 487 return albums; 488 } 489 490 async openAsset(mode: string, fileAsset: photoAccessHelper.PhotoAsset): Promise<number> { 491 Log.debug(TAG, 'openAsset start'); 492 let fd: number = await fileAsset.open(mode); 493 Log.info(TAG, 'openAsset end. fd: ' + fd); 494 if (fd <= 0) { 495 Log.info(TAG, 'openAsset Fail'); 496 } 497 return fd; 498 } 499 500 async closeAsset(fd: number, fileAsset: photoAccessHelper.PhotoAsset): Promise<void> { 501 Log.debug(TAG, 'closeAsset start'); 502 await fileAsset.close(fd); 503 } 504 505 async addPhotoToAlbumByUserFileMgr(albumUri: string, uri: string): Promise<void> { 506 Log.info(TAG, 'addPhotoAssetsDemoPromise'); 507 Log.info(TAG, 'albumUri' + albumUri); 508 Log.info(TAG, 'mediaItem.uri' + uri); 509 try { 510 let album = await this.getUserAlbumItemByUri(albumUri); 511 let predicates = new dataSharePredicates.DataSharePredicates(); 512 predicates.equalTo(photoAccessHelper.PhotoKeys.URI, uri); 513 let fetchOptions = { 514 fetchColumns: MediaConstants.FILE_ASSET_FETCH_COLUMNS, 515 predicates: predicates 516 }; 517 this.userFileMgr.getAssets(fetchOptions, async (err, fetchResult) => { 518 if (fetchResult != undefined) { 519 Log.info(TAG, 'fetchResult success'); 520 let fileAsset = await fetchResult.getFirstObject(); 521 if (fileAsset != undefined) { 522 Log.info(TAG, 'addPhotoToAlbumByUserFileMgr photo displayName : ' + fileAsset.displayName); 523 album.addAssets([fileAsset]).then(() => { 524 Log.info(TAG, 'album addPhotoAssets successfully'); 525 }).catch((err) => { 526 Log.info(TAG, 'album addPhotoAssets failed with error: ' + err); 527 }); 528 } 529 fetchResult.close(); 530 } else { 531 Log.info(TAG, 'fetchResult fail' + err); 532 } 533 }); 534 } catch (err) { 535 Log.error(TAG, 'addPhotoAssetsDemoPromise failed with error: ' + err); 536 } 537 } 538} 539 540export let userFileModel: UserFileModel = stashOrGetObject<UserFileModel>(new UserFileModel(), TAG); 541