2016-05-12 23:43:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <folly/File.h>
|
2016-09-10 02:56:02 +03:00
|
|
|
#include <folly/Optional.h>
|
2016-05-12 23:43:17 +03:00
|
|
|
#include <folly/String.h>
|
|
|
|
#include <map>
|
2016-09-10 02:56:02 +03:00
|
|
|
#include "TreeInode.h"
|
2016-05-12 23:43:17 +03:00
|
|
|
#include "eden/utils/DirType.h"
|
|
|
|
#include "eden/utils/PathFuncs.h"
|
2016-09-10 02:56:00 +03:00
|
|
|
#include "eden/utils/PathMap.h"
|
2016-05-12 23:43:17 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
|
|
|
/** Manages the write overlay storage area.
|
|
|
|
*
|
|
|
|
* The overlay is where we store files that are not yet part of a snapshot.
|
|
|
|
*
|
|
|
|
* The contents of this storage layer are overlaid on top of the object store
|
|
|
|
* snapshot that is active in a given mount point.
|
|
|
|
*
|
|
|
|
* There is one overlay area associated with each eden client instance.
|
|
|
|
*
|
2016-09-10 02:56:00 +03:00
|
|
|
* We use the Overlay to manage mutating the structure of the checkout;
|
|
|
|
* each time we create or delete a directory entry, we do so through
|
|
|
|
* the overlay class.
|
2016-05-12 23:43:17 +03:00
|
|
|
*
|
2016-09-10 02:56:00 +03:00
|
|
|
* The Overlay class keeps track of the mutated tree; if we mutate some
|
|
|
|
* file "foo/bar/baz" then the Overlay records metadata about the list
|
|
|
|
* of files in the root, the list of files in "foo", the list of files in
|
|
|
|
* "foo/bar" and finally materializes "foo/bar/baz".
|
2016-05-12 23:43:17 +03:00
|
|
|
*/
|
|
|
|
class Overlay {
|
|
|
|
public:
|
|
|
|
explicit Overlay(AbsolutePathPiece localDir);
|
|
|
|
|
2016-09-10 02:56:00 +03:00
|
|
|
/** Returns the path to the root of the Overlay storage area */
|
2016-05-12 23:43:17 +03:00
|
|
|
const AbsolutePath& getLocalDir() const;
|
|
|
|
|
2016-09-10 02:56:00 +03:00
|
|
|
/** Returns the path to the root of the materialized tree.
|
|
|
|
* This is a sub-directory of the local dir */
|
|
|
|
const AbsolutePath& getContentDir() const;
|
2016-05-12 23:43:17 +03:00
|
|
|
|
2016-09-10 02:56:02 +03:00
|
|
|
void saveOverlayDir(RelativePathPiece path, const TreeInode::Dir* dir) const;
|
|
|
|
void removeOverlayDir(RelativePathPiece path) const;
|
|
|
|
|
|
|
|
folly::Optional<TreeInode::Dir> loadOverlayDir(RelativePathPiece path) const;
|
|
|
|
|
2016-09-10 02:56:00 +03:00
|
|
|
private:
|
|
|
|
/** path to ".eden/CLIENT/local" */
|
2016-05-12 23:43:17 +03:00
|
|
|
AbsolutePath localDir_;
|
2016-09-10 02:56:00 +03:00
|
|
|
/** location of the materialized files/dirs */
|
|
|
|
AbsolutePath contentDir_;
|
2016-05-12 23:43:17 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|