Skip to content
Snippets Groups Projects
Commit 9226fe7e authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Minor fix to os_name of renamed files

parent 7be2b578
Branches
Tags
No related merge requests found
......@@ -159,16 +159,6 @@ public class NodeDAO {
return newNode;
}
/*private String getAllLevelsChildrenSelector(String path) {
String select = "(SELECT path FROM node WHERE node_id = (SELECT node_id FROM node_vos_path WHERE vos_path = ?))::varchar || '";
if (!"/".equals(path)) {
select += ".";
}
select += "*{1,}'";
return select;
}*/
private Node getNodeFromResultSet(ResultSet rs) throws SQLException {
Node node = NodeUtils.getTypedNode(rs.getString("type"));
......@@ -291,7 +281,7 @@ public class NodeDAO {
}
public void renameNode(Long nodeId, String name) {
String sql = "UPDATE node SET name = ?\n"
String sql = "UPDATE node SET name = ?\n, os_name = COALESCE(os_name, name)"
+ "WHERE path ~ ('*.' || ?)::lquery";
jdbcTemplate.update(conn -> {
......
......@@ -5,7 +5,6 @@
*/
package it.inaf.oats.vospace.persistence;
import it.inaf.oats.vospace.URIUtils;
import it.inaf.oats.vospace.datamodel.NodeProperties;
import it.inaf.oats.vospace.exception.InternalFaultException;
import it.inaf.oats.vospace.persistence.NodeDAO.ShortNodeDescriptor;
......@@ -239,14 +238,23 @@ public class NodeDAOTest {
Optional<Long> rootId = dao.getNodeId(oldPath);
assertTrue(rootId.isPresent());
assertEquals("f1", dao.getNodeOsName(oldPath));
dao.renameNode(rootId.get(), "f_pippo");
assertTrue(dao.listNode(oldPath).isEmpty());
assertTrue(dao.listNode(oldPathChild).isEmpty());
// After the first rename the os_name column has to be equal to the old name
// to avoid issues with renaming folders where some files have been uploaded
assertEquals("f1", dao.getNodeOsName(newPath));
assertTrue(dao.listNode(newPath).isPresent());
assertTrue(dao.listNode(newPathChild).isPresent());
// The second rename mustn't change the os_name column
dao.renameNode(rootId.get(), "f_pippo_second_rename");
assertEquals("f1", dao.getNodeOsName("/test1/f_pippo_second_rename"));
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment