Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files are duplicated in file set #56

Open
RasmusGOlsen opened this issue Aug 9, 2023 · 1 comment
Open

Files are duplicated in file set #56

RasmusGOlsen opened this issue Aug 9, 2023 · 1 comment
Labels
Bug Something isn't working

Comments

@RasmusGOlsen
Copy link

RasmusGOlsen commented Aug 9, 2023

When the FileSet reference is set in the file the file gets duplicated in the file set.

import pyEDAA.ProjectModel as pm


fileset = pm.FileSet("FileSetA")
file = pm.File("myfile.txt")
file.FileSet = fileset
fileset.AddFile(file)

for file in fileset.Files():
    print(file.Path)

output

myfile.txt
myfile.txt

@Paebbels Paebbels added the Bug Something isn't working label Aug 9, 2023
@Paebbels
Copy link
Member

Paebbels commented Aug 9, 2023

I think this case is covered by code on dev branch: https://github.com/edaa-org/pyEDAA.ProjectModel/pull/54/files#diff-5ca1d531578afaf790f0e51937ffa4056bdf077d1601b209c2f33c69eeb46facR835-R836

def AddFile(self, file: File) -> None:
	if file.FileSet is not None:
		raise ValueError(f"File '{file.Path!s}' is already part of fileset '{file.FileSet.Name}' and can't be assigned to an other fileset.")

	self._files.append(file)
	file._fileSet = self

There is currently no explicit check on duplicates.

I think 2 changes are needed:

  1. Adding a set to quickly identify duplicates in a fileset. Iterating a list is not so good. I might run a performance test before that change.
  2. Adding a check also on the File.FileSet property so both direction of linking files with filesets is then protected from duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Development

No branches or pull requests

2 participants