Skip to content

graph.close: only serialise to file if necessary #326

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

Merged
merged 6 commits into from
Jun 27, 2025

Conversation

mpollmeier
Copy link
Contributor

i.e. if file doesn't exist yet or there have been changes to the graph

i.e. if file doesn't exist yet or there have been changes to the graph
@mpollmeier mpollmeier requested a review from ml86 June 27, 2025 08:03
val (nodes, edges, props) = Serialization.writeGraph(this, storagePath)
logger.debug(s"closed graph: wrote $nodes nodes with $edges edges and $props properties")
if (!Files.exists(storagePath) || hasChangedSinceOpen) {
logger.info(s"closing graph: writing to storage at `$storagePath`")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might always want a log message that the graph was closed. Just with an indication if it is written or not.

logger.info(s"closing graph: writing to storage at `$storagePath`")
val (nodes, edges, props) = Serialization.writeGraph(this, storagePath)
logger.debug(s"closed graph: wrote $nodes nodes with $edges edges and $props properties")
if (!Files.exists(storagePath) || hasChangedSinceOpen) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to write the cpg if the file does not exist and no changes have been applied?
I can only think of this happening if somebody deleted the cpg externally but then it is not our concern to write it out again.

@@ -153,13 +153,15 @@ class Graph(val schema: Schema, val storagePathMaybe: Option[Path] = None) exten
def isClosed: Boolean = closed

override def close(): Unit = {
logger.debug("closing")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most people do not have their logger config set up to print the emitting class names. In those case it is not clear what it being closed. So something like "closing graph" would be much more helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"most people" don't make wise decisions :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapted, will merge on green

if hasChangedSinceOpen
} Serialization.writeGraph(this, storagePath)

logger.info("closed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some as above.

@mpollmeier mpollmeier merged commit f09d83b into master Jun 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants