mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
Fix the various lints (#1124)
This commit is contained in:
@@ -228,23 +228,17 @@ impl VfsBackend for InMemoryFs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn must_be_file<T>(path: &Path) -> io::Result<T> {
|
fn must_be_file<T>(path: &Path) -> io::Result<T> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other(format!(
|
||||||
io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"path {} was a directory, but must be a file",
|
"path {} was a directory, but must be a file",
|
||||||
path.display()
|
path.display()
|
||||||
),
|
)))
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn must_be_dir<T>(path: &Path) -> io::Result<T> {
|
fn must_be_dir<T>(path: &Path) -> io::Result<T> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other(format!(
|
||||||
io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"path {} was a file, but must be a directory",
|
"path {} was a file, but must be a directory",
|
||||||
path.display()
|
path.display()
|
||||||
),
|
)))
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn not_found<T>(path: &Path) -> io::Result<T> {
|
fn not_found<T>(path: &Path) -> io::Result<T> {
|
||||||
|
|||||||
@@ -15,45 +15,27 @@ impl NoopBackend {
|
|||||||
|
|
||||||
impl VfsBackend for NoopBackend {
|
impl VfsBackend for NoopBackend {
|
||||||
fn read(&mut self, _path: &Path) -> io::Result<Vec<u8>> {
|
fn read(&mut self, _path: &Path) -> io::Result<Vec<u8>> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&mut self, _path: &Path, _data: &[u8]) -> io::Result<()> {
|
fn write(&mut self, _path: &Path, _data: &[u8]) -> io::Result<()> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_dir(&mut self, _path: &Path) -> io::Result<ReadDir> {
|
fn read_dir(&mut self, _path: &Path) -> io::Result<ReadDir> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_file(&mut self, _path: &Path) -> io::Result<()> {
|
fn remove_file(&mut self, _path: &Path) -> io::Result<()> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_dir_all(&mut self, _path: &Path) -> io::Result<()> {
|
fn remove_dir_all(&mut self, _path: &Path) -> io::Result<()> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn metadata(&mut self, _path: &Path) -> io::Result<Metadata> {
|
fn metadata(&mut self, _path: &Path) -> io::Result<Metadata> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||||
@@ -61,17 +43,11 @@ impl VfsBackend for NoopBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn watch(&mut self, _path: &Path) -> io::Result<()> {
|
fn watch(&mut self, _path: &Path) -> io::Result<()> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwatch(&mut self, _path: &Path) -> io::Result<()> {
|
fn unwatch(&mut self, _path: &Path) -> io::Result<()> {
|
||||||
Err(io::Error::new(
|
Err(io::Error::other("NoopBackend doesn't do anything"))
|
||||||
io::ErrorKind::Other,
|
|
||||||
"NoopBackend doesn't do anything",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,15 +109,13 @@ impl VfsBackend for StdBackend {
|
|||||||
self.watches.insert(path.to_path_buf());
|
self.watches.insert(path.to_path_buf());
|
||||||
self.watcher
|
self.watcher
|
||||||
.watch(path, RecursiveMode::Recursive)
|
.watch(path, RecursiveMode::Recursive)
|
||||||
.map_err(|inner| io::Error::new(io::ErrorKind::Other, inner))
|
.map_err(io::Error::other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unwatch(&mut self, path: &Path) -> io::Result<()> {
|
fn unwatch(&mut self, path: &Path) -> io::Result<()> {
|
||||||
self.watches.remove(path);
|
self.watches.remove(path);
|
||||||
self.watcher
|
self.watcher.unwatch(path).map_err(io::Error::other)
|
||||||
.unwatch(path)
|
|
||||||
.map_err(|inner| io::Error::new(io::ErrorKind::Other, inner))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use anyhow::{bail, format_err, Context};
|
use anyhow::{bail, Context};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use memofs::Vfs;
|
use memofs::Vfs;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
@@ -91,32 +90,6 @@ impl UploadCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The kind of asset to upload to the website. Affects what endpoints Rojo uses
|
|
||||||
/// and changes how the asset is built.
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
enum UploadKind {
|
|
||||||
/// Upload to a place.
|
|
||||||
Place,
|
|
||||||
|
|
||||||
/// Upload to a model-like asset, like a Model, Plugin, or Package.
|
|
||||||
Model,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for UploadKind {
|
|
||||||
type Err = anyhow::Error;
|
|
||||||
|
|
||||||
fn from_str(source: &str) -> Result<Self, Self::Err> {
|
|
||||||
match source {
|
|
||||||
"place" => Ok(UploadKind::Place),
|
|
||||||
"model" => Ok(UploadKind::Model),
|
|
||||||
attempted => Err(format_err!(
|
|
||||||
"Invalid upload kind '{}'. Valid kinds are: place, model",
|
|
||||||
attempted
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn do_upload(buffer: Vec<u8>, asset_id: u64, cookie: &str) -> anyhow::Result<()> {
|
fn do_upload(buffer: Vec<u8>, asset_id: u64, cookie: &str) -> anyhow::Result<()> {
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://data.roblox.com/Data/Upload.ashx?assetid={}",
|
"https://data.roblox.com/Data/Upload.ashx?assetid={}",
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ pub enum InstigatingSource {
|
|||||||
ProjectNode(
|
ProjectNode(
|
||||||
#[serde(serialize_with = "path_serializer::serialize_absolute")] PathBuf,
|
#[serde(serialize_with = "path_serializer::serialize_absolute")] PathBuf,
|
||||||
String,
|
String,
|
||||||
ProjectNode,
|
Box<ProjectNode>,
|
||||||
Option<String>,
|
Option<String>,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ impl RojoTree {
|
|||||||
self.inner.root_ref()
|
self.inner.root_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_instance(&self, id: Ref) -> Option<InstanceWithMeta> {
|
pub fn get_instance(&self, id: Ref) -> Option<InstanceWithMeta<'_>> {
|
||||||
if let Some(instance) = self.inner.get_by_ref(id) {
|
if let Some(instance) = self.inner.get_by_ref(id) {
|
||||||
let metadata = self.metadata_map.get(&id).unwrap();
|
let metadata = self.metadata_map.get(&id).unwrap();
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ impl RojoTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_instance_mut(&mut self, id: Ref) -> Option<InstanceWithMetaMut> {
|
pub fn get_instance_mut(&mut self, id: Ref) -> Option<InstanceWithMetaMut<'_>> {
|
||||||
if let Some(instance) = self.inner.get_by_ref_mut(id) {
|
if let Some(instance) = self.inner.get_by_ref_mut(id) {
|
||||||
let metadata = self.metadata_map.get_mut(&id).unwrap();
|
let metadata = self.metadata_map.get_mut(&id).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ pub fn snapshot_project_node(
|
|||||||
metadata.instigating_source = Some(InstigatingSource::ProjectNode(
|
metadata.instigating_source = Some(InstigatingSource::ProjectNode(
|
||||||
project_path.to_path_buf(),
|
project_path.to_path_buf(),
|
||||||
instance_name.to_string(),
|
instance_name.to_string(),
|
||||||
node.clone(),
|
Box::new(node.clone()),
|
||||||
parent_class.map(|name| name.to_owned()),
|
parent_class.map(|name| name.to_owned()),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ impl TestServeSession {
|
|||||||
Ok(serde_json::from_str(&body).expect("Server returned malformed response"))
|
Ok(serde_json::from_str(&body).expect("Server returned malformed response"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_api_read(&self, id: Ref) -> Result<ReadResponse, reqwest::Error> {
|
pub fn get_api_read(&self, id: Ref) -> Result<ReadResponse<'_>, reqwest::Error> {
|
||||||
let url = format!("http://localhost:{}/api/read/{}", self.port, id);
|
let url = format!("http://localhost:{}/api/read/{}", self.port, id);
|
||||||
let body = reqwest::blocking::get(url)?.text()?;
|
let body = reqwest::blocking::get(url)?.text()?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user