public static void write(BaseMetadata metadata, WriteOptions options, CancellableOperationProgressBase progress = null) { if (options.HasFlag(WriteOptions.AUTO) || options.HasFlag(WriteOptions.WRITE_TO_DISK)) { MetadataFileFactory.write(metadata, progress); } if (metadata.IsImported && (options.HasFlag(WriteOptions.AUTO) || options.HasFlag(WriteOptions.WRITE_TO_DATABASE))) { using (MetadataDbCommands metadataCommands = new MetadataDbCommands()) { metadata = metadataCommands.update(metadata); } } metadata.IsModified = false; }
// update metadata from disk void reloadFromDisk_URLock(CancellationToken token) { EnterWriteLock(); ItemState = MediaItemState.LOADING; ExitWriteLock(false); MetadataFactory.ReadOptions readOptions = MetadataFactory.ReadOptions.READ_FROM_DISK; Thumbnail thumb = null; int id = 0; if (Metadata != null) { id = Metadata.Id; if (Metadata.Thumbnail == null) { // generate thumbnail readOptions |= MetadataFactory.ReadOptions.GENERATE_THUMBNAIL; } else { // save current thumb thumb = Metadata.Thumbnail; } } readMetadata_URLock(readOptions, token); if (Metadata != null && thumb != null) { // restore thumbnails Metadata.Thumbnail = thumb; } if (Metadata != null && id != 0) { // update changes to database using (MetadataDbCommands metadataCommands = new MetadataDbCommands()) { Metadata.Id = id; Metadata = metadataCommands.update(Metadata); } } }