Skip to content

Commit

Permalink
Merge pull request #141 from flatironinstitute/dont-save-empty
Browse files Browse the repository at this point in the history
Don't save empty files to zip
  • Loading branch information
WardBrian authored Jul 23, 2024
2 parents 0f7c84d + b311caa commit 692b66a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion gui/src/app/Project/ProjectSerialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export const serializeAsZip = async (
throw new Error("Error creating folder in zip file");
}
Object.entries(fileManifest).forEach(([name, content]) => {
folder.file(name, content);
if (content.trim() !== "") {
folder.file(name, content);
}
});
const zipBlob = await zip.generateAsync({ type: "blob" });

Expand Down
17 changes: 10 additions & 7 deletions gui/src/app/pages/HomePage/SaveProjectWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FunctionComponent, useCallback, useContext, useState } from "react";

import { serializeAsZip } from "@SpCore//ProjectSerialization";
import { serializeAsZip } from "@SpCore/ProjectSerialization";
import { FileRegistry, mapModelToFileManifest } from "@SpCore/FileMapping";
import { ProjectContext } from "@SpCore/ProjectContextProvider";
import saveAsGitHubGist from "@SpCore/gists/saveAsGitHubGist";
Expand Down Expand Up @@ -35,12 +35,15 @@ const SaveProjectWindow: FunctionComponent<SaveProjectWindowProps> = ({
/>
</td>
</tr>
{Object.entries(fileManifest).map(([name, content], i) => (
<tr key={i}>
<td>{name}</td>
<td>{content.length} bytes</td>
</tr>
))}
{Object.entries(fileManifest).map(
([name, content], i) =>
content.trim() !== "" && (
<tr key={i}>
<td>{name}</td>
<td>{content.length} bytes</td>
</tr>
),
)}
</tbody>
</table>
<div>&nbsp;</div>
Expand Down

0 comments on commit 692b66a

Please sign in to comment.