Use db_transaction helper class instead of using sqlite3_exec directly

This commit is contained in:
Daniel Schulte 2020-11-22 20:37:12 +01:00
parent 215de112c7
commit e47089325d
2 changed files with 6 additions and 7 deletions

View File

@ -262,11 +262,12 @@ void handle_watch_video(Video &video, bool mark_only) {
}
void handle_mark_all_videos_watched(Channel &channel) {
sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr);
{
db_transaction transaction;
for(Video &video: videos[channel.id]) {
video.set_flag(db, kWatched);
}
sqlite3_exec(db, "COMMIT TRANSACTION;", nullptr, nullptr, nullptr);
}
channel.load_info(db);
}

4
yt.cpp
View File

@ -158,7 +158,7 @@ void Channel::fetch_new_videos(sqlite3 *db, progress_info *info, std::optional<s
{"key", yt_config.api_key},
};
sqlite3_exec(db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr);
db_transaction transaction;
int processed = 0;
bool abort = false;
@ -210,8 +210,6 @@ void Channel::fetch_new_videos(sqlite3 *db, progress_info *info, std::optional<s
break;
}
}
sqlite3_exec(db, "COMMIT TRANSACTION;", nullptr, nullptr, nullptr);
}
void Channel::load_info(sqlite3 *db)