blob: 201b9c8354a6d25cea1a523bce8f7559bc408f90 [file] [log] [blame]
Patrick Venture9efef5d2019-06-19 08:45:44 -07001/*
2 * Copyright 2019 Google Inc.
3 *
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
17#include "cleanup.hpp"
18
19#include <blobs-ipmid/blobs.hpp>
Patrick Venture9b37b092020-05-28 20:58:57 -070020
Patrick Venture9efef5d2019-06-19 08:45:44 -070021#include <filesystem>
22#include <memory>
23#include <string>
24#include <vector>
25
26namespace ipmi_flash
27{
28
29std::unique_ptr<blobs::GenericBlobInterface>
30 FileCleanupHandler::CreateCleanupHandler(
31 const std::string& blobId, const std::vector<std::string>& files)
32{
33 return std::make_unique<FileCleanupHandler>(blobId, files);
34}
35
36bool FileCleanupHandler::canHandleBlob(const std::string& path)
37{
38 return (path == supported);
39}
40
41std::vector<std::string> FileCleanupHandler::getBlobIds()
42{
43 return {supported};
44}
45
46bool FileCleanupHandler::commit(uint16_t session,
47 const std::vector<uint8_t>& data)
48{
49 namespace fs = std::filesystem;
50
51 for (const auto& file : files)
52 {
53 helper->remove(file);
54 }
55
56 return true;
57}
58
59} // namespace ipmi_flash