Skip to content

Commit

Permalink
Add missing file.
Browse files Browse the repository at this point in the history
  • Loading branch information
weetmuts committed Jan 20, 2024
1 parent 1955c28 commit 33e6bd8
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/beak_stash.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright (C) 2023 Fredrik Öhrström
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "beak.h"
#include "beak_implementation.h"
#include "backup.h"
#include "log.h"
#include "origintool.h"
#include "storagetool.h"

#include<algorithm>

static ComponentId STASH = registerLogComponent("stash");

RC BeakImplementation::stash(Settings *settings, Monitor *monitor)
{
RC rc = RC::OK;
Path *cwd = sys_->cwd();
string cwds = cwd->str();

std::replace( cwds.begin(), cwds.end(), '/', '_');
cwds = string("stash_")+cwds;

Path *stash = cacheDir()->append(cwds);
local_fs_->mkDirpWriteable(stash);

if (settings->diff)
{
settings->from.type = ArgOrigin;
settings->from.origin = cwd;

Storage storage;
storage.type = FileSystemStorage;
storage.storage_location = stash;
settings->to.type = ArgStorage;
settings->to.storage = &storage;

rc = diff(settings, monitor);

return rc;
}

settings->from.type = ArgOrigin;
settings->from.origin = cwd;
Storage storage;
storage.type = FileSystemStorage;
storage.storage_location = stash;
settings->to.type = ArgStorage;
settings->to.storage = &storage;

rc = store(settings, monitor);

info(STASH, "Stashed into %s\n", stash->c_str());

return rc;
}

0 comments on commit 33e6bd8

Please sign in to comment.