Skip to content

Commit

Permalink
Merge branch 'syncback-prototype-3-fs-snapshot' of https://github.com…
Browse files Browse the repository at this point in the history
…/UpliftGames/rojo into syncback-prototype-3-fs-snapshot
  • Loading branch information
Corecii committed Sep 19, 2023
2 parents c972246 + 33ffd5a commit 1071fe8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rojo"
version = "7.3.0-uplift.12.pre.3"
version = "7.3.0-uplift.12.pre.4"
rust-version = "1.71.0"
authors = ["Lucien Greathouse <[email protected]>"]
description = "Enables professional-grade development tools for Roblox developers"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Known issues:
How to:
1. Prepare your project for assets by adding folders and project file entries for common asset locations like Workspace and ReplicatedStorage
2. Save your place file somewhere accessible
3. Syncback: `rojo syncback --input path/to/your/place.rbxl path/to/your/project.default.json`
3. Syncback: `rojo syncback --input path/to/your/place.rbxl path/to/your/project_name.project.json`
4. Confirm that the diff looks right and it will write the assets to the filesystem

Exciting features list:
Expand Down Expand Up @@ -135,7 +135,7 @@ Rojo can be installed with Aftman, a toolchain manager for Roblox projects:

```toml
[tools]
rojo = "UpliftGames/[email protected].3"
rojo = "UpliftGames/[email protected].4"
```

### From GitHub Releases
Expand Down Expand Up @@ -166,4 +166,4 @@ Pull requests are welcome!
Rojo supports Rust 1.58.1 and newer. The minimum supported version of Rust is based on the latest versions of the dependencies that Rojo has.

## License
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.
2 changes: 1 addition & 1 deletion plugin/wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rojo-rbx/rojo"
description = "Rojo enables Roblox developers to use professional-grade software engineering tools"
version = "7.3.0-uplift.12.pre.3"
version = "7.3.0-uplift.12.pre.4"
license = "MPL-2.0"
authors = ["LPGhatguy (https://lpg.space/)"]
registry = "https://github.com/upliftgames/wally-index"
Expand Down
36 changes: 33 additions & 3 deletions src/snapshot_middleware/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,33 @@ impl SnapshotMiddleware for DirectoryMiddleware {
instance: &Instance,
consider_descendants: bool,
) -> Option<i32> {
let is_preferred_class = preferred_classes().contains(instance.class.as_str());

// Directory representation is not an option if we have more than one
// child with the same name
let mut names = HashSet::new();
for child_ref in instance.children() {
let inst = dom.get_by_ref(*child_ref).unwrap();
let name = inst.name.as_str();
if !names.insert(name.to_lowercase()) {
log::info!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
if is_preferred_class && consider_descendants {
log::info!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
} else {
log::debug!("Cannot save {} as a directory because it contains 2+ children with the same name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
}
return None;
}
if !is_filename_legal_everywhere(name) {
log::info!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
if is_preferred_class && consider_descendants {
log::info!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
} else {
log::debug!("Cannot save {} as a directory because it contains a child with an invalid name: {} (it will be saved as something else instead, like an rbxm)", instance.name, name);
}
return None;
}
}

if preferred_classes().contains(instance.class.as_str()) {
if is_preferred_class {
if consider_descendants {
Some(PRIORITY_MANY_READABLE)
} else {
Expand Down Expand Up @@ -285,6 +295,14 @@ fn syncback_update(sync: &SyncbackArgs<'_, '_>) -> anyhow::Result<SyncbackNode>
}
}

if new_inst.class == "Folder" {
if fs_snapshot.files.is_empty() && new_inst.children().is_empty() {
fs_snapshot
.files
.insert(path.join(".rojo-keep"), Some(Arc::new(Vec::new())));
}
}

metadata.fs_snapshot = Some(fs_snapshot);

Ok(SyncbackNode::new(
Expand Down Expand Up @@ -462,6 +480,14 @@ fn syncback_new(sync: &SyncbackArgs<'_, '_>) -> anyhow::Result<SyncbackNode> {
}
}

if new_inst.class == "Folder" {
if fs_snapshot.files.is_empty() && new_inst.children().is_empty() {
fs_snapshot
.files
.insert(path.join(".rojo-keep"), Some(Arc::new(Vec::new())));
}
}

metadata.fs_snapshot = Some(fs_snapshot);

Ok(SyncbackNode::new(
Expand Down Expand Up @@ -675,6 +701,10 @@ pub fn snapshot_dir_no_meta(
let fs_snapshot = snapshot.metadata.fs_snapshot.as_mut().unwrap();
fs_snapshot.dirs.insert(path.to_path_buf());

// ensure .rojo-keep is deleted if we syncback and it's not needed anymore.
// it does not matter if it was actually present in the first place.
fs_snapshot.files.insert(path.join(".rojo-keep"), None);

Ok(Some(snapshot))
}

Expand Down

0 comments on commit 1071fe8

Please sign in to comment.