use explicit set of dir_obj for path, as ORM cant easily work out which dir is the right one for a path
This commit is contained in:
@@ -108,10 +108,9 @@ class Path(Base):
|
|||||||
type = relationship("PathType")
|
type = relationship("PathType")
|
||||||
path_prefix = Column(String, unique=True, nullable=False )
|
path_prefix = Column(String, unique=True, nullable=False )
|
||||||
num_files = Column(Integer)
|
num_files = Column(Integer)
|
||||||
dir_obj = relationship("Dir", secondary="path_dir_link", uselist=False)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<id: {self.id}, type={self.type}, path_prefix={self.path_prefix}, dir_obj={self.dir_obj}>"
|
return f"<id: {self.id}, type={self.type}, path_prefix={self.path_prefix}>"
|
||||||
|
|
||||||
class Dir(Base):
|
class Dir(Base):
|
||||||
__tablename__ = "dir"
|
__tablename__ = "dir"
|
||||||
@@ -718,7 +717,7 @@ def JobImportDir(job):
|
|||||||
path_obj.num_files=overall_file_cnt
|
path_obj.num_files=overall_file_cnt
|
||||||
|
|
||||||
# this is needed so that later on, when we AddDir for any dirs we find via os.walk, they have a parent dir object that is the dir for the path we are in
|
# this is needed so that later on, when we AddDir for any dirs we find via os.walk, they have a parent dir object that is the dir for the path we are in
|
||||||
parent_dir=path_obj.dir_obj
|
parent_dir=session.query(Dir).join(PathDirLink).join(Path).filter(Path.id==path_obj.id,Dir.rel_path=='').first()
|
||||||
|
|
||||||
# first time through we need dir to be the top level, we have a special if below to no recreate the top dir that AddPath created already
|
# first time through we need dir to be the top level, we have a special if below to no recreate the top dir that AddPath created already
|
||||||
dir=parent_dir
|
dir=parent_dir
|
||||||
|
|||||||
Reference in New Issue
Block a user