<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Concept on Dragotins Blog</title>
    <link>https://dragotin.codeberg.page/tags/concept/</link>
    <description>Recent content in Concept on Dragotins Blog</description>
    <image>
      <title>Dragotins Blog</title>
      <url>https://dragotin.codeberg.page/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://dragotin.codeberg.page/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.152.1</generator>
    <language>en</language>
    <copyright>2022-2026 Klaas Freitag - Content is licensed under the Creative Commons Attribution 4.0 International License</copyright>
    <lastBuildDate>Fri, 13 Mar 2015 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://dragotin.codeberg.page/tags/concept/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>ownCloud ETags and FileIDs</title>
      <link>https://dragotin.codeberg.page/posts/owncloud-etags-and-fileids/</link>
      <pubDate>Fri, 13 Mar 2015 00:00:00 +0000</pubDate>
      <guid>https://dragotin.codeberg.page/posts/owncloud-etags-and-fileids/</guid>
      <description>&lt;p&gt;Often questions come up about the meaning of FileIDs and ETags. Both values are metadata that the ownCloud Server stores for each of the files and directories in the server database. These values are fundamentally important for the integrity of data in the overall system. Here are some thoughts about what they are why these are so important.This is mainly from a clients point of view, but there are other use cases as well.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Often questions come up about the meaning of FileIDs and ETags. Both values are metadata that the ownCloud Server stores for each of the files and directories in the server database. These values are fundamentally important for the integrity of data in the overall system. Here are some thoughts about what they are why these are so important.This is mainly from a clients point of view, but there are other use cases as well.</p>
<h2 id="etags">ETags</h2>
<p>ETags are strings that describe exactly one specific version of a file (example: 71a89a94b0846d53c17905a940b1581e).</p>
<p><img alt="data2" loading="lazy" src="/posts/owncloud-etags-and-fileids/images/data2.jpg">Whenever the file changes, the ownCloud server will make sure that the ETag of the specific file changes as well. It is not important in which way the ETag changes, it also does not have to be strictly unique, it&rsquo;s just important that it changes reliably if the file changes for whatever reason. However, ETags should not change if the file was not changed, otherwise the client will download that file again.</p>
<p>In addition to that, The ETags of the parent directories of the file have to change as well, up to the root directory. That way client systems can detect changes that happen somewhere in the file tree. This is in contrast to normal computer file systems where only the modification time of the direct parent of a file is changing.</p>
<h2 id="file-ids">File IDs</h2>
<p>FileIDs are also strings that are created once at the creation time of the file (example: 00003867ocobzus5kn6s).</p>
<p><img alt="data3" loading="lazy" src="/posts/owncloud-etags-and-fileids/images/data3.jpg">But contrary to the ETags, the file IDs should never ever change over the files lifetime. Not on an edit of the file, and also not if the file is renamed or moved. One of the important usages of the FileID is to detect renames and moves of a file on the server.</p>
<p>The FileID is used as an unique key to identify a file. FileIDs need to be unique within one ownCloud, and in inter-owncloud connections, they must be compared together with the ownCloud server instance id.</p>
<p>Also, the FileIDs must never be recycled or reused.</p>
<h2 id="checksums">Checksums?</h2>
<p>Often ETags and FileIDs are confused with checksums such as MD5 or SHA1 sums over the file content.</p>
<p>Neither ETags nor FileIDs are, even if there are similarities: Especially the ETag can be seen as a checksum over the file content. However, file checksums are way more costly to compute than just a value that only needs to change somehow.</p>
<h2 id="what-happens-if">What happens if&hellip;?</h2>
<p>Let&rsquo;s make a thought experiment and consider what it would mean especially for sync clients if either fileID or ETag gets lost from the servers database.</p>
<p>If ETags are lost, clients loose the ability to decide if files have changed since the last time that was checked by the clients. So what happens is that the client will download the files again, byte-wise compare them to the local file and use the server file if the files differ. A conflict file will be created. Because the ETag was lost, the server will create new ETags on download. This could be improved by the server creating more predictable ETags based on the storage backends capabilities.</p>
<p>If the ETags are changed without reason, for example because a backup was played back on the server, the clients will consider the ones with changed ETags as changed and redownload them. Conflict handling will happen as described if there was a local change as well.</p>
<p>For the user, this means a lot of unnecessary downloads as well as potential conflicts. However, there will not be data loss.</p>
<p>If FileIDs got lost or changed, the problem is that renames or moves on server side can no longer be detected. That would result in a new download of files in the good case. If a fileID however changes to something that was used before, that can result in a rename that overwrites an unrelated file. That is because clients might still have the FileID associated with another file.</p>
<p>Hopefully this little post explains the importance of the additional metadata that we maintain in ownCloud.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Csync for ownCloud Client 1.1.0 - A New Sync Engine</title>
      <link>https://dragotin.codeberg.page/posts/csync-for-owncloud-client-1-1-0-a-new-sync-engine/</link>
      <pubDate>Thu, 11 Oct 2012 00:00:00 +0000</pubDate>
      <guid>https://dragotin.codeberg.page/posts/csync-for-owncloud-client-1-1-0-a-new-sync-engine/</guid>
      <description>&lt;p&gt;Along with todays &lt;a href=&#34;https://owncloud.com/blog/owncloud45-community&#34;&gt;ownCloud 4.5&lt;/a&gt; release we released the new &lt;a href=&#34;http://owncloud.org/sync-clients&#34;&gt;ownCloud Client 1.1.0&lt;/a&gt; with a new syncing concept.&lt;/p&gt;
&lt;p&gt;This blog will shed some light on the details. I apologize, it&amp;rsquo;s a long read.&lt;/p&gt;
&lt;h2 id=&#34;time-issues&#34;&gt;Time Issues&lt;/h2&gt;
&lt;p&gt;ownCloud Client versions 1.0.x worked with &lt;a href=&#34;http://csync.org&#34;&gt;csync&lt;/a&gt;s traditional way of using the &lt;a href=&#34;http://en.wikipedia.org/wiki/MAC_times&#34;&gt;file modification times&lt;/a&gt; to detect updates between the two repositories that should be synced to each other. That works fine and conforms to our idea to ideally not use any other metadata in syncing than what the file system has anyway.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Along with todays <a href="https://owncloud.com/blog/owncloud45-community">ownCloud 4.5</a> release we released the new <a href="http://owncloud.org/sync-clients">ownCloud Client 1.1.0</a> with a new syncing concept.</p>
<p>This blog will shed some light on the details. I apologize, it&rsquo;s a long read.</p>
<h2 id="time-issues">Time Issues</h2>
<p>ownCloud Client versions 1.0.x worked with <a href="http://csync.org">csync</a>s traditional way of using the <a href="http://en.wikipedia.org/wiki/MAC_times">file modification times</a> to detect updates between the two repositories that should be synced to each other. That works fine and conforms to our idea to ideally not use any other metadata in syncing than what the file system has anyway.</p>
<p><a href="http://dragotin.files.wordpress.com/2012/10/timeflies.jpg"><img alt="Time flies" loading="lazy" src="/posts/csync-for-owncloud-client-1-1-0-a-new-sync-engine/images/timeflies.jpg" title="Time flies"></a></p>
<p>However, there is one drawback which we all know from daily life: If at least two parties sync on time its important that all clocks are set exactly the same way. Remember good crime movies where a bank robbery always starts with a clock adjustment of all gangsters? We have exactly the same in ownClouds syncing: All involved have to have the same time setting, otherwise modification times of files can not be compared reliably.</p>
<p>There are solutions for computers to set the exact time (like ntp) so in general that works. However, in real life scenarios these are not reliable because either people do not have them started on the system or because the daemon updates the time once in a while and in that time span the clock skews already too much.</p>
<p>Users all the time reported problems with that and other experts continued to advise that we never get around that problems if we don&rsquo;t change something fundamental and go away from pure time based syncing.</p>
<p>Well, we did that with our <a href="http://owncloud.org/sync-clients/releases/">csync version 0.60.0</a> which is the sync engine for ownCloud Client 1.1.0.</p>
<h2 id="an-unique-id">An Unique Id</h2>
<p>Now, every file and directory inside a sync directory has an unique Id associated. The idea is that the Id changes if the file changes. So in the sync process the need for a file update in either direction can be computed by comparing the two Ids of the file. If the id has changed on one repository the file was changed there and needs to be synced to the other side.</p>
<p>The Ids are generated on the ownCloud server and one challenge for the client is to always download the correct Id of a file. The Ids are just random tags for a file version. It is not associated to the file content as MD5 sums would be. Actually it was a frequent advise to use MD5 sums or a similar approach which digests the files content to detect updates. That would have come very handy because that means comparing file contents directly and, more important, it&rsquo;s reproducable on either side. Also the client would have been able to recalculate the MD5-Sum of the local files and would not have depended on a local database with Ids that were pulled from the server before.</p>
<p>But we decided against hashes. Calculating MD5-Sums is costly in terms of CPU and time, especially for large files. The CPU problem is small on clients, but not on servers where a lot of clients connect to. Even though the sums can be calculated during upload, the problems remain for the case where the server does not see the upload stream, think of the &ldquo;mount my Dropbox&rdquo; case.</p>
<p>For files on the ownCloud server, the Id is always updated when the file gets updated. On the client side the last Id of a file is in the client database. It is invalidated in case the files modification time changed meanwhile to detect local changes.</p>
<h2 id="change-propagation">Change Propagation</h2>
<p>Another remarkable change in the 1.1.0 client is that change events in the file tree propagate up to the top directory on the owncloud server, ie. if a file changes in a directory, the id of the directory changes as well as the one of its parent directory etc.</p>
<p>That means that to detect if a file tree has changed, it&rsquo;s enough to check the top most directories Id. If that has changed, ok, than the client needs to dig deeper, but in the not so rare case that nothing has changed, the one call is enough to detect that. That dramatically lowers the server load with clients because instead of digging through the whole directory structure what we did with the 1.0.x series it is a few requests now.</p>
<h2 id="csync-and-owncloud-for-success">CSync and ownCloud for Success</h2>
<p>These are very intrusive changes to csync. For example, we had to add two additional fields to the database, add code that is able to build a representation of the local file tree from the database and make csync query for the file Ids from the server if needed. Deep under the hood the updater, reconciler and propagator code needed changes to work with the Ids. All these changes did not go back to csync upstream yet.</p>
<p>To not conflict with the upstream version of csync we decided to rename our csync version to ocsync. But: This is a temporar solution for the time we need to catch up with upstream again. That will take a while until everything is sorted again but we will work on that.</p>
<p>I am are very excited about the new version of csync. But obviously there are other changes in the ownCloud Client 1.1.0 which will be subject of another blog post.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
