mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Allow turning off file watching in memofs.
Also preemptively bumping version to 0.1.3 so I don't forget on next release
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1083,7 +1083,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memofs"
|
name = "memofs"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"fs-err",
|
"fs-err",
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ uuid = { version = "0.8.1", features = ["v4", "serde"] }
|
|||||||
winreg = "0.6.2"
|
winreg = "0.6.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
memofs = { version = "0.1.0", path = "memofs" }
|
memofs = { version = "0.1.3", path = "memofs" }
|
||||||
|
|
||||||
anyhow = "1.0.27"
|
anyhow = "1.0.27"
|
||||||
bincode = "1.2.1"
|
bincode = "1.2.1"
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
# memofs Changelog
|
# memofs Changelog
|
||||||
|
|
||||||
## Unreleased Changes
|
## Unreleased Changes
|
||||||
|
* Added `set_watch_enabled` to `Vfs` and `VfsLock` to allow turning off file watching.
|
||||||
|
|
||||||
|
## 0.1.2 (2020-03-29)
|
||||||
|
* `VfsSnapshot` now implements Serde's `Serialize` and `Deserialize` traits.
|
||||||
|
|
||||||
## 0.1.1 (2020-03-18)
|
## 0.1.1 (2020-03-18)
|
||||||
* Improved error messages using the [fs-err](https://crates.io/crates/fs-err) crate.
|
* Improved error messages using the [fs-err](https://crates.io/crates/fs-err) crate.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "memofs"
|
name = "memofs"
|
||||||
description = "Virtual filesystem with configurable backends."
|
description = "Virtual filesystem with configurable backends."
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@@ -140,13 +140,18 @@ pub enum VfsEvent {
|
|||||||
/// the public interfaces to this type.
|
/// the public interfaces to this type.
|
||||||
struct VfsInner {
|
struct VfsInner {
|
||||||
backend: Box<dyn VfsBackend>,
|
backend: Box<dyn VfsBackend>,
|
||||||
|
watch_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VfsInner {
|
impl VfsInner {
|
||||||
fn read<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Arc<Vec<u8>>> {
|
fn read<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Arc<Vec<u8>>> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let contents = self.backend.read(path)?;
|
let contents = self.backend.read(path)?;
|
||||||
self.backend.watch(path)?;
|
|
||||||
|
if self.watch_enabled {
|
||||||
|
self.backend.watch(path)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Arc::new(contents))
|
Ok(Arc::new(contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +164,11 @@ impl VfsInner {
|
|||||||
fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> io::Result<ReadDir> {
|
fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> io::Result<ReadDir> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let dir = self.backend.read_dir(path)?;
|
let dir = self.backend.read_dir(path)?;
|
||||||
self.backend.watch(path)?;
|
|
||||||
|
if self.watch_enabled {
|
||||||
|
self.backend.watch(path)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(dir)
|
Ok(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,6 +224,7 @@ impl Vfs {
|
|||||||
pub fn new<B: VfsBackend>(backend: B) -> Self {
|
pub fn new<B: VfsBackend>(backend: B) -> Self {
|
||||||
let lock = VfsInner {
|
let lock = VfsInner {
|
||||||
backend: Box::new(backend),
|
backend: Box::new(backend),
|
||||||
|
watch_enabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -229,6 +239,16 @@ impl Vfs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Turns automatic file watching on or off. Enabled by default.
|
||||||
|
///
|
||||||
|
/// Turning off file watching may be useful for single-use cases, especially
|
||||||
|
/// on platforms like macOS where registering file watches has significant
|
||||||
|
/// performance cost.
|
||||||
|
pub fn set_watch_enabled(&self, enabled: bool) {
|
||||||
|
let mut inner = self.inner.lock().unwrap();
|
||||||
|
inner.watch_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/// Read a file from the VFS, or the underlying backend if it isn't
|
/// Read a file from the VFS, or the underlying backend if it isn't
|
||||||
/// resident.
|
/// resident.
|
||||||
///
|
///
|
||||||
@@ -318,6 +338,15 @@ pub struct VfsLock<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VfsLock<'_> {
|
impl VfsLock<'_> {
|
||||||
|
/// Turns automatic file watching on or off. Enabled by default.
|
||||||
|
///
|
||||||
|
/// Turning off file watching may be useful for single-use cases, especially
|
||||||
|
/// on platforms like macOS where registering file watches has significant
|
||||||
|
/// performance cost.
|
||||||
|
pub fn set_watch_enabled(&mut self, enabled: bool) {
|
||||||
|
self.inner.watch_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/// Read a file from the VFS, or the underlying backend if it isn't
|
/// Read a file from the VFS, or the underlying backend if it isn't
|
||||||
/// resident.
|
/// resident.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user