Skip to content

Commit

Permalink
Include size in the serverpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Baughn committed Dec 17, 2016
1 parent ca1395d commit 3e125fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ rec {
modtype = mod.modType or "Regular";
required = mod.required or true;
side = mod.side or "BOTH";
size = fileSize (pack.clientModsDir + "/" + mod.filename);
url = packUrlBase + "mods/" + mod.encoded;
}) pack.clientMods;
}; in revless // {
Expand Down Expand Up @@ -191,6 +192,7 @@ rec {
{ name = "index.html"; path = ./index.html; }
{ name = "packs"; path = combinedPack; }
{ name = "ServerPack.xml"; path = packFile; }
{ name = "params.xml"; path = packFile.paramsText; }
{ name = "MCUpdater-Bootstrap.jar"; path = preconfiguredMCUpdater; }
];

Expand Down Expand Up @@ -242,4 +244,15 @@ rec {
echo -e "import sys, urllib as ul\nsys.stdout.write(ul.pathname2url(sys.stdin.read()))" > program
python program < $textPath > $out
'');

/**
* Gets the size of a file.
*/
fileSize = file: import (runCommand "size" {
inherit file;
preferLocalBuild = true;
allowSubstitutes = false;
} ''
stat -L -c %s "$file" > $out
'');
}
1 change: 1 addition & 0 deletions lib/serverpack.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<MD5><xsl:value-of select="attrs/attr[@name='md5']/string/@value" /></MD5>
<ModType><xsl:value-of select="attrs/attr[@name='modtype']/string/@value" /></ModType>
<ModPath><xsl:value-of select="attrs/attr[@name='modpath']/string/@value" /></ModPath>
<Size><xsl:value-of select="attrs/attr[@name='size']/int/@value" /></Size>
</Module>
</xsl:for-each>
<xsl:for-each select="attr[@name='configs']/attrs/attr">
Expand Down

0 comments on commit 3e125fa

Please sign in to comment.