Loading transfer_service/db_connector.py +37 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,43 @@ class DbConnector(object): vospacePathList.append(el["vos_path"]) return vospacePathList def getNodesToBeDeleted(self): "Returns a path list of files to be deleted with also the corresponding deletion timestamp." with self.getConnection() as conn: try: cursor = conn.cursor(cursor_factory = RealDictCursor) cursor.execute(""" WITH all_nodes AS ( SELECT name, os_name, node_id, parent_path, path, relative_path, owner_id, location_id, null as deleted_on FROM node UNION SELECT name, os_name, node_id, parent_path, path(parent_path, node_id) AS path, path(parent_relative_path, node_id) AS relative_path, owner_id, location_id, deleted_on FROM deleted_node ) SELECT base_path || '/' || owner_id || os_path AS abs_os_path, an.deleted_on FROM ( SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT (CASE WHEN os_name IS NOT NULL THEN os_name ELSE name END) AS name, p.node_id FROM all_nodes n JOIN ( SELECT UNNEST(string_to_array(relative_path::varchar, '.')) AS rel_id, node_id FROM all_nodes ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id ORDER BY os_path ) AS all_paths JOIN all_nodes an ON all_paths.node_id = an.node_id JOIN location l ON an.location_id = l.location_id JOIN storage s ON s.storage_id = l.storage_src_id WHERE all_paths.os_path NOT IN (SELECT os_path FROM node_os_path); """) result = cursor.fetchall() except Exception as e: if not conn.closed: conn.rollback() print(e) return result ##### Job ##### def jobExists(self, jobId): Loading Loading
transfer_service/db_connector.py +37 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,43 @@ class DbConnector(object): vospacePathList.append(el["vos_path"]) return vospacePathList def getNodesToBeDeleted(self): "Returns a path list of files to be deleted with also the corresponding deletion timestamp." with self.getConnection() as conn: try: cursor = conn.cursor(cursor_factory = RealDictCursor) cursor.execute(""" WITH all_nodes AS ( SELECT name, os_name, node_id, parent_path, path, relative_path, owner_id, location_id, null as deleted_on FROM node UNION SELECT name, os_name, node_id, parent_path, path(parent_path, node_id) AS path, path(parent_relative_path, node_id) AS relative_path, owner_id, location_id, deleted_on FROM deleted_node ) SELECT base_path || '/' || owner_id || os_path AS abs_os_path, an.deleted_on FROM ( SELECT node_id, '/' || string_agg(name, '/') AS os_path FROM ( SELECT (CASE WHEN os_name IS NOT NULL THEN os_name ELSE name END) AS name, p.node_id FROM all_nodes n JOIN ( SELECT UNNEST(string_to_array(relative_path::varchar, '.')) AS rel_id, node_id FROM all_nodes ) AS p ON n.node_id::varchar = p.rel_id ORDER BY p.node_id, nlevel(n.path) ) AS j GROUP BY node_id ORDER BY os_path ) AS all_paths JOIN all_nodes an ON all_paths.node_id = an.node_id JOIN location l ON an.location_id = l.location_id JOIN storage s ON s.storage_id = l.storage_src_id WHERE all_paths.os_path NOT IN (SELECT os_path FROM node_os_path); """) result = cursor.fetchall() except Exception as e: if not conn.closed: conn.rollback() print(e) return result ##### Job ##### def jobExists(self, jobId): Loading