# Implementing new versioning schemes

**URL:** https://forum.syncthing.net/t/implementing-new-versioning-schemes/260
**Category:** Development
**Created:** [May 25, 2014, 7:06pm UTC](https://forum.syncthing.net/t/implementing-new-versioning-schemes/260 "2014-05-25T19:06:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [May 25, 2014, 7:06pm UTC](https://forum.syncthing.net/t/implementing-new-versioning-schemes/260/1 "2014-05-25T19:06:43Z")

</div>

The first versioning scheme is “Simple File Versioning”. It’s useful on its own but also serves as a template for how to implement new versioning schemes. The versioning stuff is modular and can be extended simply by adding new types that implement the `Versioner` interface.

To start out, simply copy the file [https://github.com/calmh/syncthing/blob/master/versioner/simple.go](https://github.com/calmh/syncthing/blob/master/versioner/simple.go) to a new file in the same directory. You will need to rename the type and constructor functions and modify the code in `init()` to register the new constructor function with a unique name.

The constructor function is passed a `map[string]string` containing parameters from the configuration. Assuming you named your type `Custom` and registered it with the name `custom`, it could be activated on a repository with the following elements in `config.xml`:

```xml
 <repository id="wt2" directory="~/wt2">
    <node id="GYRZZQBIRNPV4T7TC52WEQYJ3TFDQW6MWDFLMU4SSSU6EMFBK2VA"></node>
    <versioning type="custom">
        <param key="foo" value="bar" />
    </versioning>
</repository>

```

The constructor would receive a `map[string]string{"foo": "bar"}` object.

The `Archive()` method is called each time before a file would be replaced or deleted. It is expected to move the file to an archive of some sort (or deleted if the relevant versioning algorithm decides it is not to be saved). After a successfull run of `Archive()` the file name given as the parameter should no longer exist.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [May 12, 2017, 1:17pm UTC](https://forum.syncthing.net/t/implementing-new-versioning-schemes/260/2 "2017-05-12T13:17:02Z")

</div>


