You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "oowl (via GitHub)" <gi...@apache.org> on 2023/06/28 17:26:49 UTC
[GitHub] [incubator-opendal] oowl opened a new pull request, #2564: feat(binding/lua): add rename and create_dir operator function
oowl opened a new pull request, #2564:
URL: https://github.com/apache/incubator-opendal/pull/2564
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #2564: feat(binding/lua): add rename and create_dir operator function
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #2564:
URL: https://github.com/apache/incubator-opendal/pull/2564#discussion_r1246037867
##########
bindings/lua/src/lib.rs:
##########
@@ -124,6 +126,43 @@ fn operator_write<'a>(
}
}
+fn operator_create_dir<'a>(_: &'a Lua, (operator, path): (LuaTable<'a>, String)) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if path.is_empty() {
Review Comment:
Please don't do those check, they are rust core's job.
##########
bindings/lua/src/lib.rs:
##########
@@ -124,6 +126,43 @@ fn operator_write<'a>(
}
}
+fn operator_create_dir<'a>(_: &'a Lua, (operator, path): (LuaTable<'a>, String)) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if path.is_empty() {
+ return Err(LuaError::external("path is empty"));
+ }
+
+ let res = op.create_dir(path.as_str());
+ match res {
+ Ok(_) => Ok(()),
+ Err(e) => Err(LuaError::external(e)),
+ }
+}
+
+fn operator_rename<'a>(
+ _: &'a Lua,
+ (operator, src, dst): (LuaTable<'a>, String, String),
+) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if src.is_empty() {
+ return Err(LuaError::external("src is empty"));
+ }
+
+ if dst.is_empty() {
+ return Err(LuaError::external("dst is empty"));
+ }
+
+ let res = op.rename(src.as_str(), dst.as_str());
Review Comment:
It'e better to use `&src, &dst`
##########
bindings/lua/src/lib.rs:
##########
@@ -124,6 +126,43 @@ fn operator_write<'a>(
}
}
+fn operator_create_dir<'a>(_: &'a Lua, (operator, path): (LuaTable<'a>, String)) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if path.is_empty() {
+ return Err(LuaError::external("path is empty"));
+ }
+
+ let res = op.create_dir(path.as_str());
+ match res {
+ Ok(_) => Ok(()),
+ Err(e) => Err(LuaError::external(e)),
+ }
+}
+
+fn operator_rename<'a>(
+ _: &'a Lua,
+ (operator, src, dst): (LuaTable<'a>, String, String),
+) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if src.is_empty() {
Review Comment:
the same.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #2564: feat(binding/lua): add rename and create_dir operator function
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #2564:
URL: https://github.com/apache/incubator-opendal/pull/2564#discussion_r1246018573
##########
bindings/lua/src/lib.rs:
##########
@@ -124,6 +126,63 @@ fn operator_write<'a>(
}
}
+fn operator_create_dir<'a>(_: &'a Lua, (operator, path): (LuaTable<'a>, String)) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if path.is_empty() {
+ return Err(LuaError::external("path is empty"));
+ }
+
+ let res = op.is_exist(path.as_str());
Review Comment:
There is no need to do this here. Our rust core part will handle this.👀
##########
bindings/lua/src/lib.rs:
##########
@@ -124,6 +126,63 @@ fn operator_write<'a>(
}
}
+fn operator_create_dir<'a>(_: &'a Lua, (operator, path): (LuaTable<'a>, String)) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if path.is_empty() {
+ return Err(LuaError::external("path is empty"));
+ }
+
+ let res = op.is_exist(path.as_str());
+ match res {
+ Ok(exist) => {
+ if exist {
+ return Err(LuaError::external("path is exist"));
+ }
+ }
+ Err(e) => return Err(LuaError::external(e)),
+ }
+
+ let res = op.create_dir(path.as_str());
+ match res {
+ Ok(_) => Ok(()),
+ Err(e) => Err(LuaError::external(e)),
+ }
+}
+
+fn operator_rename<'a>(
+ _: &'a Lua,
+ (operator, src, dst): (LuaTable<'a>, String, String),
+) -> LuaResult<()> {
+ let op = operator.get::<_, ODOperator>("_operator")?;
+ let op = op.operator;
+
+ if src.is_empty() {
+ return Err(LuaError::external("src is empty"));
+ }
+
+ if dst.is_empty() {
+ return Err(LuaError::external("dst is empty"));
+ }
+
+ let res = op.is_exist(src.as_str());
Review Comment:
ditto.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo merged pull request #2564: feat(binding/lua): add rename and create_dir operator function
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #2564:
URL: https://github.com/apache/incubator-opendal/pull/2564
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org