[SOLVED] Empty folder size counted as 128 bytes in Windows

Syncthing counts each empty folder as 128 bytes, and this size is included in the local/global state. Windows, on the other hand, reports them as having 0 bytes.

Is this correct?



Is it right that the folder is ntfs compressed?

Yes, it actually is. Although I have just tried to disable the compression, and there seems to be no difference.

1 Like

This is a fictive size to account for the fact that they have a nonzero cost and overhead to sync, and to provide some metric for the in sync percentage. The fact that we don’t also do this with zero sized files is the reason for your NaN % complete issue with only zero sized files…

1 Like

I see. While probably not a big deal, this does mean that the folder size reported in Syncthing will almost always be larger than the actual size on the disk, right? I would guess that having empty folders somewhere in the directory tree is quite common.

Something’s actual size on disk is anyway a matter of opinion and perspective. :wink: But yes, folder size according to Syncthing is not just the sum of reported user-facing file sizes. It’s usually quite close to it though. (It’s also not specifically about empty directories, 128 bytes is what we consider any directory – or symlink – costs.)

I’m thinking we should probably add an overhead to files as well to make sure a 0 byte file in fact results in a non-100% sync completion…

Hmm, would it not be possible to go the other way round, keep the file size as is, and report folders/symlinks as 0 bytes too? Then Syncthing’s state would correspond with the actual size on the disk, right?

As for the “NaN%” thing, how about simply using “0%” or “95%” instead of it, when the total size of a folder is 0 bytes? Another way that has come to me mind would be to count the percentage out of the total file number instead of the size, but that would likely require writing new code specifically for it.

Actual size on disk is also a matter of perspective. Physically a file also has some filesystem overhead on the disk (NTFS Master File Table, EXT Inodes, Block Groups etc) - this can be quite a lot, depending on FS structure and file distribution. Many OS will never report all overhead, so how much disk is used by something always depends on your perspective.

1 Like

Folder sizes for us are primarily about computing completion percentages. For that purpose it’s helpful if every item has a nonzero cost. We settled on a 128 bytes for all non-file items a long time ago, but could equally well go with for example the length of the name plus length of the data. In the end “size on disk” doesn’t really mean anything what with metadata, compression, sparseness, block sizes, etc., at least not anything that Syncthing can compute or care about.

I am not really convinced, but it does not really matter for myself that much (apart from the “NaN” thing), so I will stop here. I do think that it can be confusing, when the size reported in Syncthing does not correspond with the size shown in the operating system. I must say though that I had not noticed this before, and it was only when dealing with empty folders while testing that something started to feel wrong.

However, I do not think that this size counting method is documented anywhere, or is it? Except maybe in the code itself, of course.

The thing to realize here is that there is no single truth about what the operating system shows and that it varies a lot from OS to OS and FS to FS. On my Mac a one byte file shows as one byte or 4 KiB depending on how you ask, except on an external disk where it is instead 128 KiB (exfat), an empty directory is 64 bytes in size (a directory with things in it will be larger), but again probably takes up more space and is apparently 128 KiB on exfat. On Windows a small file will in fact take up quite little space as it gets stored inside it’s directory entry, so it has zero size on disk and the space is maybe accounted somewhere else… Mix in compression, sparse files, and different filesystems here and it’s all approximations and abstractions all the way down.

If there was a single, correct, ground truth then I could buy the argument that we should show the same thing. But there isn’t, and hence I don’t think it matters.

So if you want to get really confused, dig into the details of how files and directories are stored on your system and how much space they actually take up. :slight_smile: The only thing I can be sure about is that a directory does not in fact use zero bytes on disk, or you could store an infinite amount of them there.


I wonder how other synchronisation software handles this. I have been using Syncthing exclusively for ~1 year, but I had used several others before. Unfortunately, I had not really paid attention to file/folder size reporting in them then. I have got curious now though :nerd_face:.

Note that once you actually have a megabyte or so of data in the folder all the numbers you see in the GUI get rounded. You’ll have to dig into the API and compare closely with your OS to see differences. (Hence my “this doesn’t actually matter” opinion :slight_smile: )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.